Search code examples
c#uwpmicrocontrollerwinusb

Using USB bulk transfer for data acquisition


Below I have included information about the specific microcontroller and library I am using for the microcontroller only to provide a little context and in case someone has experience with them. I am really looking for some broad answers about USB bulk communication vs other USB styles of communication.

I am developing a UWP based app to communicate with a TI TM4C based microcontroller. The microcontroller has several analog and digital sensors which need to be transmitted and logged/displayed in the application.

I would like to use the WinUSB.sys driver for USB communication with the device because I have read about a lot of problems with the usbser.sys driver and I want to avoid using System.IO.Ports namespace because of well documented issues with event reliability. The WinUSB driver would allow me to use the Windows.Devices.USB namespace instead.

The communication structure I am envisioning between the application and the device would be simple requests for data from the application and the device sending the contents of its data registers (<50 bytes). Other commands from the application would set certain output values manually and would anticipate an acknowledgement from the device that this was done successfully or any error that occurred.

TI provides a bundled library for the microcontroller called TivaWare USB Library

1) Does anyone foresee any issues using bulk transfers for communication between the application and the device? Particularly, I was concerned with this description of bulk transfer found in the Windows Documentation "Therefore, when the bus is busy with other transfers, bulk data can wait indefinitely."

2) Bulk transfer is described as having error detection and retries baked in. Does this mean using other methods I would need to implement some kind of error detection for data transmitted like a CRC?

3) This page describing using WinUSB with UWP apps seems to imply that the WinUSB driver can be used with a CDC device class, does this mean that I can communicate with a CDC class device with the Windows.Devices.USB namespace or am I still stuck using System.IO.Ports since CDC devices expose virtual com ports? (At least when using the USBser.sys driver. Does it work the same with the WinUSB driver?)


Solution

  • We ended up using the TivaWare library keyboard example to help us build our own HID device and write custom HID report descriptors. C# UWP does indeed have excellent support for HID devices and we used the humaninterfacedevice library. The TivaWare library is difficult to work with if anyone is considering going down the same path.