Using the Serial and USB ports with VB.NET
I was playing around with my USB GPS receiver the other day and started to wonder how hard it would be to integrate it into my applications (more on this in the future). The first challenge I had was to be able to talk with it via the USB port and gather the location data.
It was a late at night and my mind was not functioning at 100%, or even 25%. So I want out to Google MSN Search to find some code examples of talking to USB devices with VB.NET and there was next to nothing in the world.
It was only after a few minutes that my brain caught up and it hit me that the S in USB was for serial. A simple fact and the fact that it took me a matter of minutes to wake up to this should have caused me to head to bed and get some sleep but no such luck.
Moral of my story, if you are looking at talking with either a Serial port or a USB device you can access it with some of the code from this sample.
It is an older sample but works great. Saves you the pain of having to interact with or wrap the Win32 APIs for serial access yourself.
Comments
- Anonymous
April 07, 2005
check this out...
http://www.icsharpcode.net/opensource/sharpusblib/ - Anonymous
April 08, 2005
One bit of clarification. Not every USB device can speak the RS-232 lanaguage. In other words your USB hard drive is most likely not going to answer and respond to commands as a COM port. - Anonymous
April 11, 2005
In the sample code you provided, how do you configure it to use a USB port? Normally you have com1, com2 etc... How would I talk to say, USB device 3 via com?
Thanks,
Russ