c# hid usb 卡死,C#中的USB HID编程

Hello Everyone,

We are having a device which complies with USB HID class specification, which also has five endpoints to exchange datas with host.

To be frank, we are using florian C# hid lib for building the host application.

http://www.florian-leitner.de/index.php/2007/08/03/hid-usb-driver-library/.  We are successful in enumeration and device connection but data loss is happening in the communication.

Let me explain you the scenario, device is programmed in such a way that it has to send the data packets of length 64 in bytes and the 1st byte of data packet contains information about the packet number[0-255] and the rest 63 bytes used for communication

payload. The device does the process of adding the packet number in the data packet and store them in to endpoints in serial fashion.

Now the same information has to be read in the host side. We are calling the Readfile API of kerner32.dll inorder to collect the data from the device. Here comes the challenges. The moment device connected to the PC it starts transmitting the data

packets to the PC. So, when we call the Readfile API there comes the packet shuffling.

Lets say we are reading from the Endpoint0 [EP0], the packet number may be 160 and next reading from EP1, the packet number was 161, from EP2 the paket number was 162, from EP3 the packet number was 163 but the EP4th reading gave us surprise.

It read 174th packet.

Its like 160,161,162,163,174 and next sequence can be 165,166,167,168,179.

But the same code without modification, reads sequentialy. Like 0,1,2,3,4 and next sequence was 5,6,7,8,9.

Can anyone tell us why this uncertainty and what could be approximate root cause for not getting read the packet number sequentialy?

Thanks and Regards,

Yashath

解决方案But the same code without modification, reads sequentialy. Like 0,1,2,3,4 and next sequence was 5,6,7,8,9.

What does it mean 'modification' ?? What did you modify in code ?

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值