[C#,HID]如何使用USBHIDDRIVER.dll在HID连接中写入数据
public void sendStartCMD()
{
byte[] startCMD = new byte[8];
//Start
startCMD[0] = 255;
//Mode
startCMD[1] = 0;
//USync
startCMD[2] = 28;
//ULine
startCMD[3] = 20;
//tSync
startCMD[4] = 20;
//tRepeat - High
startCMD[5] = 0;
//tRepeat - Low
startCMD[6] = 0x01;
//BusMode
startCMD[7] = 0xF4;
//send the command
usbI.Connect();
usbI.write(startCMD);
}
您好,我是C#和HID USB通讯的新手。
我是发送数据时遇到问题。
我正在尝试使用USBHIDDRIVER.dll。我检查好了接收数据。
但是,当我尝试使用上面的函数发送数据时,usbI.write()函数总是返回false。
当我用Beagle检查时,没有数据输出。
以及当我检查下面的函数时,NumberOfBytesWritten有0函数执行后。
Hi, I am new to C# and HID USB communication.
I am having trouble with sending data.
I am trying with USBHIDDRIVER.dll. and I checked receiving data well.
However, When I try sending data with the function above, usbI.write()function always returns false.
When I checked with Beagle, there is no data out.
and also when I checked the function below, "NumberOfBytesWritten" has 0 after the function excuted.
Result = USBSharp.WriteFile(hidHandle, ref outputReportBuffer[0], outputReportBuffer.Length, ref NumberOfBytesWritten, 0);
如何正确发送数据?如果有遗漏的话请告诉我。
非常感谢,
How can I send data properly? Please let me know if there is something I am missing.
Thank you very much,
您应该查看您的图书馆文档,以获取更多信息。如果没有提供文档(或者文档很差),那么您可以检查库源代码并尝试理解真正的问题(或者用基础Winapi调用替换库函数调用)。
You should check out your library documentation, in order to get additional info. If the documentation is not provided (or is poor) then you might inspect the library source code and try to understand the real problem (or replace the library function call with the underlying Winapi calls).