hid_wrtite返回-1,通过调用hid_error返回函数不正确。

Apple Joke Apple Joke 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
程序输出:
Starting F:\code\jiriheng\CommandTestApp\autoCommandTestApp\release\autoCommandTestApp.exe...
DLL_PROCESS_ATTACH Begin
DLL_PROCESS_ATTACH:autocommandtestapp.exe,ghijt32.dll
RegQueryValueEx(SYSTEM\CurrentControlSet\Services\) fail:2
LdSysCtrlDllName(C:\Inetpub\ftproot\Tipray\LdTerm\LdHook32.dll)
autocommandtestapp.exe Begin LoadLibrary(C:\Inetpub\ftproot\Tipray\LdTerm\LdHook32.dll)
DLL_PROCESS_ATTACH:f:\code\jiriheng\commandtestapp\autocommandtestapp\release\autocommandtestapp.exe:ldhook32.dll <1>
autoCommandTestApp.exe try hook...
[LdSysHook]==>HookFile::Init() <autoCommandTestApp.exe> InitCount<1>[LdSysHook]GH_SetHook(ZwQuerySystemInformation) success Process=<1976><autoCommandTestApp.exe>autoCommandTestApp.exe is Not Safe App
LoadLibrary(C:\Inetpub\ftproot\Tipray\LdTerm\LdHook32.dll) Success
Dewvice Handle:57610928

Manufacturer String: Touch Devic

Product String: Touch Device

Serial Number String: 00000000001A


Write Res = -1,error:函数不正确。
Read Ret = 0

部分代码:
#include "autocommandtest.h"
#include "ui_autocommandtest.h"
#include "../HidLib/hidapi.h"
#include "touchdevice.h"
#include "QDebug"
#include <windows.h>
#include <QString>

#define MAX_STR 255
#pragma comment(lib,"setupapi.lib")
#pragma comment(lib,"hid.lib")

AutoCommandTest::AutoCommandTest(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::AutoCommandTest)
{
ui->setupUi(this);


int res;
unsigned char buf[64];
wchar_t wstr[MAX_STR];
wchar_t *str_s = NULL;
hid_device *handle;
int i;


// Open the device using the VID, PID,
// and optionally the Serial number.
handle = hid_open(TOUCH_ViD, TOUCH_PiD_1, NULL);
qDebug("Dewvice Handle:%d\n",handle);

// Read the Manufacturer String
res = hid_get_manufacturer_string(handle, wstr, MAX_STR);
qDebug("Manufacturer String: %ls\n", wstr);

// Read the Product String
res = hid_get_product_string(handle, wstr, MAX_STR);
qDebug("Product String: %ls\n", wstr);

// Read the Serial Number String
res = hid_get_serial_number_string(handle, wstr, MAX_STR);
qDebug("Serial Number String: %ls", wstr);
qDebug("\n");

// Send a Feature Report to the device


buf[0] = (INITIATIVE_REPORT); // First byte is report number
buf[1] = (VERSION);
buf[2] = (VER_BOARD_TYPE_GET);

// Set the hid_read() function to be non-blocking.
hid_set_nonblocking(handle, 1);

res = hid_write(handle, buf, 64);

qDebug("Write Res = %d,error:%ls",res,hid_error(handle));
// Read requested state
res = hid_read_timeout(handle, buf, 64,100);
if (res < 0)
{
qDebug("Unable to read()\n");
}
else
{
qDebug("Read Ret = %d\n",res);
}

// Print out the returned buffer.
for (i = 0; i < res; i++)
qDebug("buf[%d]: %d\n", i, buf[i]);

hid_close(handle);
}

AutoCommandTest::~AutoCommandTest()
{
delete ui;
}


这里面使用的hid.lib库是通过VS2010编译出来的,为什么write何read都不成功?急急急急
...全文

相关推荐

29Linux基础命令详解——用户管理.docx

29Linux基础命令详解——用户管理

云计算练习生

科技服务机构如何通过数据分析增强服务竞争力?.docx

科易网基于40亿+科创知识图谱数据库,深度探索AI技术在技术转移、成果转化、技术经纪、知识产权、产业创新、科技招商等垂直领域的多样化应用场景,研究科技创新领域的AI+数智化解决方案,推动科技创新与产业创新智能化发展。

BIZKEEN

vue+springboot基于 Java 的南昌实利广告公司的员工管理系统的设计与实现_oj680rl3毕业设计源码数据库.zip

vue+springboot基于 Java 的南昌实利广告公司的员工管理系统的设计与实现_oj680rl3毕业设计源码数据库.zip

源码论文专家

车辆缺陷分割数据集4000张json格式.zip

数据集格式:labelme格式(不包含mask文件,仅仅包含jpg图片和对应的json文件) 图片数量(jpg文件个数):4000 标注数量(json文件个数):4000 标注类别数:1 标注类别名称:["defect"] 每个类别标注的框数: defect count = 8740 总框数:8740 使用标注工具:labelme=5.5.0 所在仓库:firc-dataset 图片分辨率:640x640 标注规则:对类别进行画多边形框polygon 重要说明:可以将数据集用labelme打开编辑,json数据集需自己转成mask或者yolo格式或者coco格式作语义分割或者实例分割 特别声明:本数据集不对训练的模型或者权重文件精度作任何保证

不会仰游的河马君

高校如何利用技术转移服务转化科研成果并提升影响力?.docx

高校如何利用技术转移服务转化科研成果并提升影响力?

BIZKEEN
评论
收藏 已收藏
分享
返回顶部
Apple Joke
C++ 语言 65,214 成员 250,514 内容