[C#,HID]如何使用USBHIDDRIVER.dll在HID连接中写入数据 [英] [C#, HID] How to write data in HID connection with using USBHIDDRIVER.dll

查看:522
本文介绍了[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).


这篇关于[C#,HID]如何使用USBHIDDRIVER.dll在HID连接中写入数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆