Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do I need to write my own host side USB driver for a CDC device

This may not be considered to be directly programming related but I am at a loss to know where else to ask. I have tried looking at a variety of websites but so far Google has not been my friend.

I am having trouble finding out whether I need to write my own device driver for the various windows/linux/mac platforms that the device I am developing may be connected to, or whether the functionality is provided by the standard drivers.

My device is a USB CDC (communications device) that appears as a COM: port. It also includes a battery charger that will, once the device has been enumerated require the full 5 unit load (500mA) supply current that can be drawn from the USB connector. My problem is that if the USB driver in the host decides that it cannot deliver the full supply current then it should fail to enumerate the device.

If, as a fallback, I provide a second configuration set that only allows the device to draw 1 unit load from the interface connector will the standard drivers enumerate the device using this configuration.

like image 482
uɐɪ Avatar asked Jul 24 '09 10:07

uɐɪ


People also ask

What is USB CDC host?

The CDC driver allows the scanner or cradle to emulate a serial port when connected via USB. A virtual COM port is assigned to the scanning device.

What is CDC ACM driver?

The CDC-ACM class provides a serial interface for connecting devices such as modems to an embedded system. The package provides a CDC-ACM host class driver for a USB stack. The system allows a USB serial port device to be plugged into the host and recognized as a remote serial port.

How does a USB device driver work?

A USB client driver is the software installed on the computer that communicates with the hardware to make the device function. If the device belongs to a device class supported by Microsoft, Windows loads one of the Microsoft-provided USB drivers (in-box class drivers) for the device.

What is USB CDC ACM?

USB CDC (Communications Device Class) ACM (Abstract Control Model) is a vendor-independent publicly documented protocol that can be used for emulating serial ports over USB.


1 Answers

You need to write a .inf file for Windows that ties up your device VID and PID with the system usbser.sys. Mine looks like this (Replace YourCompany as necessary, put in your VID and PID (in hex), and change the DriverVer line to whatever date and version you want):

; -----------------------------------------------------------------------------
; XP/2000 USB Comms Port Setup
; -----------------------------------------------------------------------------

[Version] 
DriverVer=12/03/2008,1.0.0000.0000
Signature="$Windows NT$"
Class=Ports 
ClassGUID={4d36e978-e325-11ce-bfc1-08002be10318} 
Provider=%YourCompany% 

[DestinationDirs]
DefaultDestDir=10,system32\drivers
DriverCopyFiles=12

[ControlFlags]
ExcludeFromSelect = *

[Manufacturer] 
%YourCOmpany%=YourCompanySerialPort 

[YourCompanySerialPort] 
%YourCompanyUSBSerialPort%=YOURCOMPANYUSB,USB\VID_1234&PID_ABCD

; 
; Win 2000/XP
;
[YOURCOMPANYUSB]
Include=mdmcpq.inf
CopyFiles=FakeModemCopyFileSection

[YOURCOMPANYUSB.HW] 
AddReg=YOURCOMPANYUSBAddReg.HW 

[YOURCOMPANYUSBAddReg.HW] 
HKR,,DevLoader,0,*ntkern 
HKR,,NTMPDriver,,"usbser.sys" 

[YOURCOMPANYUSB.Services] 
AddService=usbser, 0x00000002, FuncDrv_Service_Inst 

[FuncDrv_Service_Inst] 
DisplayName=%USBFilterString% 
ServiceType= 1 
StartType = 3 
ErrorControl = 0 
ServiceBinary = %12%\usbser.sys 

[Strings] 
YourCompany="YourCompany" 
YourCompanySerialPort="Your Company USB Serial Port" 
USBFilterString = "USB Serial Service"

Note this works with 32 bit OSs only. It also works with Vista although the file header doesn't say so!

Be aware that some versions of usbser.sys have significant problems, including bluescreening, for example when transferring packets that are exact multiples of 64 bytes. If you're using XP SP2 or previous then install hotfix KB943198. XP SP3 and Vista are fine.

For the Mac you simply need to report your device class correctly and the driver scan picks up the correct drivers. (Windows ignores the device class which is why you need to supply the .inf file).

EDIT: Sorry, I should have been clearer. This will not fail to enumerate if it can't draw the full load - I'm not sure that's possible.

like image 70
Vicky Avatar answered Oct 18 '22 19:10

Vicky