4
\$\begingroup\$

I am writing specifications for a product and need help to minimize its future need of maintenance.

In order to be able to be (optionally) monitored from the Internet the device is supposed to have a USB CDC port to connect it to a computer (I am now developing it as a python script on raspberry) able to poll data from it (less than 10 byte a minute, speed is not the problem here) and generate a nice webpage.

My concern is to minimize the need for future work on this communication capability feature: we decided to make it as a pr stunt but we expect to be used by a minority of our customers, spending days every year maintaining and fixing the code is not an option.

Computer-side we decided to open source the code and, of course, also the AT command for the device. Device side, what worries me is the need for drivers.

What USB class should I put my device into for it to be recognized as a COM port without the need of distributing drivers? I.E. if I make it adhere to Communication Devices Class specification can I have it recognized as a com port thru "standard, omni-present" drivers?

\$\endgroup\$

2 Answers 2

4
\$\begingroup\$

You probably want a CDC serial port. I'm going to disagree with laptop2d here, although HID drivers (e.g. ones for a usb mouse and keyboard) are common, I don't see how you would use any of the standard drivers for serial-like communication. You could of course write your own HID driver, or maybe there is a company out there selling them.

Windows versions from Vista onward (and probably earlier too) include a usb CDC serial driver called usbser.sys. There are as far as I can tell two major versions, one in windows Vista/7/8/8.1 and one in windows 10.

For the first version, you need to provide an inf file, to link your USB VID/PID to the driver, then windows will load it. The driver is a bit rubbish, it makes no attempt to recover from transient disruptions on the bus, and we've had trouble getting through European standard immunity tests with it. Due to a driver bug, it is not possible to recover a dropped connection purely in software (!!).

The windows 10 version is better. If you set the right device class and subclass (02/02, IIRC), windows will load the driver without an inf. It will still have a yellow ! in device manager though, so for a professional look you'll still want that inf. If you use an inf, it will have to be signed, and a code signing cert will set you back somewhere under £100.

You could also buy comercial driver from e.g. Thesycon. They are much better than the built in windows one, and they will provide customised distributables. Costs ££££s though.

I understand linux support for CDC serial ports is good, no driver needed (though maybe some udev rules), and I have no idea about Mac.

This all assumes you do the USB yourself on a USB equipped microcontroller, using the appropriate libraries, and then sort out a driver. Another option would be to work with someone like FTDI. They can probably provide drivers if you use one of their usb/serial chips.

\$\endgroup\$
8
  • 2
    \$\begingroup\$ The HID driver is not restricted to mouses and keyboards. That is just one configuration for it. Since the dawn of USB, Windows has had support for pretty much any type of HID device, and if you dive into the spec you'll see there is a huge amount of scope for defining your own custom device. For such a low data rate it would be my pick in terms of cross platform/version compatibility and ease of implementation (both PC software and embedded). \$\endgroup\$
    – Jon
    Commented Jul 6, 2017 at 16:46
  • 1
    \$\begingroup\$ I don't know of any serial-like HID drivers with wide availability though, and that seemed to be something the asker was looking for. CDC is built into windows (albeit not very well) and is likley to get improving support in the future. Let me see if I can make that clearer. \$\endgroup\$
    – Jack B
    Commented Jul 6, 2017 at 16:49
  • 2
    \$\begingroup\$ The CDC (communication) class is horrible from USB standpoint - the interface does not have good data throttling protocol, and all data sync occurs by hardware IN-NAK activity. This activity comes at hardware level and results in nearly continuous polling of the endpoint at 3 - 5 us (microsecond!!!) polling rate. Since this activity is broadcasted by USB star architecture to every branch and connected device, it contaminates the whole USB tree and is ugly. Since the CDC has a deep legacy roots in RS232, I doubt very much that it can be improved, ever. HID class is much more friendly. \$\endgroup\$ Commented Jul 6, 2017 at 19:00
  • 1
    \$\begingroup\$ Win7 usber.sys polls at about 10us intervals I think, and slows down if the bus is busy. One small mercy is that the win10 version only polls when some software has an open handle on the port, so that cuts the rubbish traffic a bit. Yes, it's pretty horrible from a bus point of view. But it is supported without needing a kernel mode driver (because usbser.sys is available out of the box). If anyone can give a way of doing serial-like communication with HID without writing a kernel mode driver, that would make a great answer, and I'll upvote it. \$\endgroup\$
    – Jack B
    Commented Jul 6, 2017 at 19:19
  • \$\begingroup\$ Probably I should have specified it better - when I think embedded and open source I think LINUX. We will release the code and a pre-baked image for a raspberry pi. If one day raspberries "go down" we`ll move to another cheap embedded thing. So seems that my only hope to have something that once plugged into a computer is seen a com port to read and write on is to use a CDC class device? \$\endgroup\$ Commented Jul 7, 2017 at 7:56
2
\$\begingroup\$

You'll want to look at hid com port drivers. If you can make your device look like an HID com port then most devices will have drivers to support USB HID.

If not then you'll have to supply drivers the old fashioned way.

\$\endgroup\$
1
  • \$\begingroup\$ +1 I agree with your recommendation. See my comment on CDC bus pollution issue. \$\endgroup\$ Commented Jul 6, 2017 at 19:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.