当前位置: 技术问答>linux和unix
linux下hid设备读写的问题
来源: 互联网 发布时间:2017-05-05
本文导语: #include #include #include #include #include #include #include #include #include #include int main(int argc,char **argv) { int fd; int rtn,ret=0; int i,j=0; struct hiddev_report_info rinfo; struct hiddev_usage_ref uref; struct hiddev_field_info finfo; s...
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
int main(int argc,char **argv)
{
int fd;
int rtn,ret=0;
int i,j=0;
struct hiddev_report_info rinfo;
struct hiddev_usage_ref uref;
struct hiddev_field_info finfo;
struct hiddev_usage_ref_multi urefs;
struct hiddev_devinfo dinfo;
struct hiddev_collection_info cinfo;
unsigned char bufw[21]={0x02,0x08,0xce,0,0,0,0,0,0,0};
unsigned char recv[21]={0};
//printf("argc = %dn",argc);
//打开设备文件
fd=open("/dev/usb/hiddev0",O_RDWR);
if(fd > 0)
{
printf("open hid success!,fd = %dn",fd);
}
//
rinfo.report_type=HID_REPORT_TYPE_OUTPUT;
rinfo.report_id=HID_REPORT_ID_FIRST;
ret=ioctl(fd,HIDIOCGREPORTINFO,&rinfo);
if(ret != 0)
{
printf("ioctl one failed!n");
close(fd);
return -1;
}
for(i=0;i
#include
#include
#include
#include
#include
#include
#include
#include
#include
int main(int argc,char **argv)
{
int fd;
int rtn,ret=0;
int i,j=0;
struct hiddev_report_info rinfo;
struct hiddev_usage_ref uref;
struct hiddev_field_info finfo;
struct hiddev_usage_ref_multi urefs;
struct hiddev_devinfo dinfo;
struct hiddev_collection_info cinfo;
unsigned char bufw[21]={0x02,0x08,0xce,0,0,0,0,0,0,0};
unsigned char recv[21]={0};
//printf("argc = %dn",argc);
//打开设备文件
fd=open("/dev/usb/hiddev0",O_RDWR);
if(fd > 0)
{
printf("open hid success!,fd = %dn",fd);
}
//
rinfo.report_type=HID_REPORT_TYPE_OUTPUT;
rinfo.report_id=HID_REPORT_ID_FIRST;
ret=ioctl(fd,HIDIOCGREPORTINFO,&rinfo);
if(ret != 0)
{
printf("ioctl one failed!n");
close(fd);
return -1;
}
for(i=0;i