Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I make a custom USB device show up in Windows as a COM Port?

I have developed a USB device that communicates with linux over a simple but proprietary interface and some custom Linux drivers. My goal is to port this to Windows without writing windows drivers. What I would like to do is find an open source or inbuilt class driver for windows that would look like a COM port in Windows. Then I would tailor the embedded software to match what ever protocol and descriptors the virtual COM port expects to see.

The idea would be that I could plug my device in to a Windows machine and a relatively high speed COM port would appear with out me having to develop Windows drivers for it.

I have been looking at the USB CDC (Communications Device Class) documentation and it looks promising, but I don't know which sub interface would be best to use so that it would show up as a COM port.

Has anyone here done any work like this before or could provide some insight? Specifically:

  1. Are there virtual COM drivers "built in" to windows or would I need a 3rd party driver.
  2. Which CDC sub class should I use for simple RS232 emulation (No need for modem AT commands, etc)
  3. Is there a better option to do what I am trying to do.

Thanks

like image 594
CodePoet Avatar asked Aug 23 '11 18:08

CodePoet


1 Answers

There is a USB-to-serial driver built in to Windows that will do what you want. It is called usbser.sys:

http://support.microsoft.com/kb/837637

You will have to write an INF file and distribute that to your users, but that will not be too hard because it is only a few kilobytes of text and you can find examples online.

I'm not aware of any great documentation for this driver by Microsoft, so my advice would be to find some other device that uses it, such as Pololu Wixel, and copy what they did.

Here are the device descriptors we used and the special control tranfers we had to implement: https://github.com/pololu/wixel-sdk/blob/master/libraries/src/usb_cdc_acm/usb_cdc_acm.c

You can see our INF file, wixel_serial.inf, by downloading the software and looking in the drivers folder: http://www.pololu.com/docs/0J46/3.a (There are other files in there that are not necessary for you.)

You can also look at the Arduino Uno because they use the same driver.

Whatever you do, please don't use our USB Vendor ID in your product! You need to get your own.

Update: In Windows 10, you don't need an INF file anymore because of the new usbser.inf driver that comes with Windows.

like image 109
David Grayson Avatar answered Nov 15 '22 18:11

David Grayson