Ports and Interfaces > USB

Chapter 13: Sending an Output Report to the Device

(1/2) > >>

phadley:
I have two problems sending output reports to my HID from my .NET application:

1) In my copy of the USB Complete book, the code to marshal the write buffer to un-managed memory is missing. (page 328)  Is this a mistake, or is it intentional?  Without it, my application sometimes writes bad data to my HID.  It was tricky to find the problem because the bug was intermittent, and only on certain PCs.  (I have also read that the numBytesWritten parameter to Writefile should be marshalled as well.  For both parameters, I use Marshal.AllocHGlobal() to allocate unmanaged memory, copy the value, and then pass IntPtr to WriteFile.)

2) When I use a USB 2.0 hub to communicate with my device, I get 0 back from numBytesWritten after a successful WriteFile (or a successful GetOverlappedResult).  My USB snooper sees three CSPLIT transmissions of the data between the PC and the hub.  However, the snooper sees none of this data between the hub and the device.  Is there something special I have to do in my software to support USB 2.0 hubs??

Thanks.

Phil

 

Jan Axelson:
1. My website has the most current and robust versions of the code:

http://www.lvr.com/hidpage.htm#MyExampleCode

2. No.

Jan

phadley:
Thanks for your reply!  Follow up questions:

1)  The code posted here also does not marshall the write buffer to un-managed memory.  The bug I get using this code shows up as garbage data on the device, but only intermittently, and when I send the report continuously, and from one particular application.  I fixed the problem by marshalling the buffer and passing an IntPtr to the unmanaged memory to WriteFile.

2)  I agree with you that no software changes should be necessary.  Can you give any suggestions as to what's causing the problem?

Phil

Jan Axelson:
1. Thanks for reporting this.

2. Connect the protocol analyzer between the device and hub to find out what is happening at the device. If you're using a software analyzer, use whatever debugging tools you have to find out how the device is responding to received OUT packets.

Jan 

phadley:
One more follow up:

2)  I tried connecting the USB snooper on either side of the hub, and none of the data that I sent appears between the hub and the device.  However, between the PC and the hub, I see three CSPLIT transmissions, each one containing the entire report.  It's like the PC makes three attempts at sending the data (which gets blocked by the hub), and then gives up.

Any advice or direction for troubleshooting this problem would be very appreciated, and thanks for doing this PORTS forum!

Phil

Navigation

[0] Message Index

[#] Next page

Go to full version