tags:

views:

126

answers:

3

I have read many codes and none match each other.. I did little bit of programming but one thing i' confused about is: how many ways you can read a USB (how many classes or libraries i have to call to do such a thing)? when you use .serial port( does that mean you are reading a serial port or even the USB uses the same class or library)? it is my first time trying to read from USB and totally clueless on how to start. if i can figure out the first step I can then proceed...ANy hints will be greatly appreciated,

+1  A: 

There is no means to directly "read USB" in .NET. Interacting with the bus itself is done by device drivers.

As to how you'll interact with a particular device, this depends entirely on the device. If you can provide some information about what you're wishing to connect to, I or others may be of more assistance.

Adam Robinson
You can use WinUSB: http://en.wikipedia.org/wiki/WinUSB
Yann Ramin
@theatrus: WinUSB is a standard device driver that provides a serial stream (and can be used similar to a serial port). If the device supports it, then you can use WinUSB. This is not reading and writing directly to the USB port.
Adam Robinson
@Adam: winusb is *not* CDC or serial port emulation. It allows probing USB devices, and reading/writing their end-point streams - the same functionality that a kernel level driver would accomplish. The only limit to WinUSB is the lack of isochronous support (bulk and interrupt only).
Yann Ramin
@theatrus: I said it provides a serial stream (specifically a named pipe), *not serial port emulation*. Again, a device must support the WinUSB profile in order to use it. It is *not* general purpose USB IO.
Adam Robinson
Downvoter care to explain why?
Adam Robinson
@Adam: Then what is general purpose USB IO, since apparently we have a different definition? winusb can be registered as the driver for any device (with the .inf file, excepting class based devices and isochronous endpoints), and allow access to all of the endpoints. It can send control requests. It can read/write from the bulk and interrupt endpoints.
Yann Ramin
@theatrus: There is no such thing as "general purpose USB IO", which was the entire point of my answer. My point is that the driver--in this case, WinUSB--does the actual communication over the bus, and the driver in turn exposes an API. WinUSB exposes a very general API that is not tailored to a particular device, but the fact remains that you are not "reading USB" or "writing USB", you are directing a particular driver to read and write data from and to the bus. The fact that you're excluding *any* device means that this is not completely general-purpose.
Adam Robinson
A: 

Use LibUSBDotNet. It is said to be good.

You can also directly interface to WinUSB, which is what newer LibUSB versions use.
Yann Ramin
A: 
AMissico