Author Topic: Question about sending > 64 bytes from PC to device  (Read 10168 times)

bmt22033

  • Member
  • ***
  • Posts: 3
Question about sending > 64 bytes from PC to device
« on: February 17, 2013, 09:24:55 pm »
First, let me say that I am new to USB development and thank you for sharing your Generic HID source.  I'm working on a project that requires me to send data from my C# application to an HID class device.  Initially, I only needed to send 50 bytes of data to the device and I was able to accomplish that by building an output report buffer and sending it via an interrupt transfer.  However, now I need to send quite a bit more data than that.  I actually have 3 different "types" of data that I need to send:

Type A = 50 bytes
Type B = 2068 bytes
Type C = 40024 bytes

I'm not a firmware developer so I don't understand how all of this works on the firmware side and unfortunately, I'm not sure that the person who *is* responsible for doing it is well versed in this sort of thing, either.  Can anyone briefly summarize how I would go about sending data of Type B and Type C to the device?  Do I need to fragment my data into 64 byte chunks and add some kind of sequence number to it so that the firmware will know how to reassemble it?  I appreciate any pointers that you may have!

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: Question about sending > 64 bytes from PC to device
« Reply #1 on: February 18, 2013, 11:35:10 am »
The HID class supports sending long reports, but it's generally more efficient to send large amounts of data in bulk transfers, which the HID class doesn't support. For bulk transfers you could use a USB virtual serial port or WinUSB.

The host application requests USB transfers. A single transfer can have 40,024 or more bytes. Dividing the data into transactions and scheduling them on the bus is done at a lower level; the host application doesn't need to worry about it.

On the device side, the firmware needs to manage the transactions. A good way to start is to find similar example code for the hardware and use it as a model.

See:

http://lvr.com/serport.htm#usb_virtual_com_ports
http://lvr.com/winusb.htm