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

前端 未结 5 1302
抹茶落季
抹茶落季 2020-12-30 09:40

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

相关标签:
5条回答
  • 2020-12-30 09:55

    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.

    0 讨论(0)
  • 2020-12-30 09:55

    I am not sure about power question but ther is pleanty CDC drivers (or I think there is) so you could use one. For the power question, the solution with many configuration is probably good one, I have never encountered this in work (I have USB analyzer) but at home sometimes when I have 3 or more different devices that requires power from USB I got failed enumeration. I supose this is operating system choice if it can't supply power to new device it cut's it off (sensible choice as it can't power it). This is my gues rather checking USB standart.

    0 讨论(0)
  • 2020-12-30 10:07

    If your device is connecting as USB CDC-ACM device to the windows desktop host, the windows desktop already provides the driver usbser.sys. But there are some some issues in windows Vista. You just need the inf to install the usbser.sys on desktop. For WinCE you do not have the driver and for you need to write or get one from any third party vendor. Here is one

    http://www.em.avant-garde-lab.com/Products.html

    If your device specifies itself as self powered in its device descriptor then the host would rely on the devices self power capability. You can check at usb.org for details. Thanks.

    0 讨论(0)
  • 2020-12-30 10:13

    If your device reports a device ID that the host OS already supports, then they won't need a driver.

    You may need to impersonate an existing USB uart. Data sheets are readily available. (But I figure you already knew that.)

    I'm not sure that the host OS will honour your multi-configuration idea.

    But give it a punt so we all know!

    0 讨论(0)
  • 2020-12-30 10:16

    You are correct on the driver question. When the device is plugged in and goes through the enumeration process it is required to stay < 100mA. The host will interrogate and determine the configuration(s). If there are more than one which support different power levels, then the driver will need to decide to select the appropriate configuration. If there is only high-power and it is not available, then it will not enumerate the device. In general, the standard driver doing CDC wouldn't be aware of the different device level configurations that would possible and so would require some degree of customization to handle them.

    0 讨论(0)
提交回复
热议问题