Rudy01
Rudy01

Reputation: 1087

Windows form application for USB port

Previously I have work with Windows Form application to establish some RS232 connection. I used the already provided serial port component (SerialPort), and I was able to establish RS232 communication relatively easy.

Now, I was wondering if there will be something similar in Winodows Form application to establish a USB communication ?

It seems there is this WinUSB API that provides a very low level interfacing with the device. However, I am not sure how easy will that be? Also, not sure how easy will it be to integrate into Windows Form application ?!

Will there be a simpler version of such USB interface API?

I don't have to stick to Visual Studio. Is there other c++ USB API, besides WinUSB, that is more standard that people use? I would like to develop a GUI API that does some communication over USB. If need be, I can use Python or some other tools if it facilitates the process?

Thanks in advance.

Upvotes: 1

Views: 2112

Answers (1)

Mats Petersson
Mats Petersson

Reputation: 129504

Although USB is a serial protocol, you can't treat USB like a serial port:

It's dependant on what the actual device is. For example a mobile phone, may provide several "endpoints" for USB, one being a serial port to use the phone as a modem, one as a storage device allowing you to transfer photos and music files to/from the phones storage, and as a camera device that you can take photos with. All of these have different behaviour and need a USB driver-plugin to make it behave correctly - these are typically shipped with Windows, and your phone will appear as COM5:, the E: or "Samsung Galaxy S3 Mini" drives and as a camera under the "cameras and scanners".

Of course, you can programmatically open all these devices, but it is done as the device-type that they present as on the inside of windows (so you use serial port functions or file functions or camera functions).

You CAN also write a device driver for a device, if you have sufficient details of how it works.

But there's no real way to "open the port". The USB API is a driver API, not a user-mode API. Here's a page to start from to understand USB drivers: http://msdn.microsoft.com/en-gb/library/windows/hardware/ff540215%28v=vs.85%29.aspx

There is a WinUSB driver, which allows a single application to access a single device, assuming you know how to operate that device.

Upvotes: 1

Related Questions