qt 通过hid获取指定usb设备 并读取数据

上传者: 14874791 | 上传时间: 2022-04-16 14:53:32 | 文件大小: 10KB | 文件类型: RAR
文件夹中包含hidapi.h hidapi.dll hidapi.lib,我是在windows10系统中用VS2013编译的release版本,我用于qt的调用,是可以实现的。 调用过程: int res; res = hid_init(); wchar_t wstr[MAX_STR]; int i; // Open the device using the VID, PID, // and optionally the Serial number. handle = hid_open(0x0483, 0x5750, NULL); if(handle == NULL) { qDebug() << "NULL-----------------------NULL" ; return; } else { qDebug() << " not ------------NULL-----------------------NULL" ; } // Read the Manufacturer String res = hid_get_manufacturer_string(handle, wstr, MAX_STR); wprintf(L"Manufacturer String: %s\n", wstr); // Read the Product String res = hid_get_product_string(handle, wstr, MAX_STR); wprintf(L"Product String: %s\n", wstr); // Read the Serial Number String res = hid_get_serial_number_string(handle, wstr, MAX_STR); wprintf(L"Serial Number String: (%d) %s\n", wstr[0], wstr); // Read Indexed String 1 res = hid_get_indexed_string(handle, 1, wstr, MAX_STR); wprintf(L"Indexed String 1: %s\n", wstr); qDebug("hid read start"); int res = hid_set_nonblocking(handle, 0); while (1) { res = hid_read(handle,buf,sizeof(buf)); QString asd ; for(int i = 0;i < sizeof(buf);i++) { char str[20]; sprintf(str , "%02x",buf[i]); asd+=str ; } if(!cardInfo.contains(asd.toUpper())) { cardInfo.append(asd.toUpper() ); for(int i = 0;i < cardInfo.size() ;i++) { dealWithData( cardInfo[i]); } } }

文件下载

资源详情

[{"title":"( 3 个子文件 10KB ) qt 通过hid获取指定usb设备 并读取数据","children":[{"title":"HID-QT","children":[{"title":"hidapi.lib <span style='color:#111;'> 5.15KB </span>","children":null,"spread":false},{"title":"hidapi.h <span style='color:#111;'> 13.54KB </span>","children":null,"spread":false},{"title":"hidapi.dll <span style='color:#111;'> 12.00KB </span>","children":null,"spread":false}],"spread":true}],"spread":true}]

评论信息

  • m0_46599313 :
    压缩文件坏掉了
    2020-11-11

免责申明

【只为小站】的资源来自网友分享,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,【只为小站】 无法对用户传输的作品、信息、内容的权属或合法性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论 【只为小站】 经营者是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。
本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二条之规定,若资源存在侵权或相关问题请联系本站客服人员,zhiweidada#qq.com,请把#换成@,本站将给予最大的支持与配合,做到及时反馈和处理。关于更多版权及免责申明参见 版权及免责申明