1

I'm using an embedded device (bare metal program running on it) which is connected via USB and appears as serial interface on an connected host PC. This works perfectly with all tested Linux variants and all Windows up to Win 7. Unfortunately with Windows 10 there are larger problems: COM port can't be opened easily (means several retries are necessary) and sometimes an existing connection stops working.

The funny thing is: opening of the COM port includes calls to SetCommState() and GetCommState() where SetCommState() fails - also when it is used with exactly the same parameters like they are returned from GetCommState(). Repeating this procedure several times then is successful, latest after 10 retries SetCommState() works.

On host PC an INF file is used which does nothing more than declaring own VID/PID (which fits to the embedded device) but then points to Windows-internal driver usbser.sys:

[Version]
Signature="$Windows NT$"
Class=Ports
ClassGuid={4D36E978-E325-11CE-BFC1-08002BE10318}
Provider=%MFGNAME%
LayoutFile=layout.inf
DriverVer=08/17/2001,5.1.2600.0

[Manufacturer]
%MFGNAME%=DeviceList, NTx86, NTamd64 

[DestinationDirs]
DefaultDestDir=12

[SourceDisksFiles]

[SourceDisksNames]

;------------------------------------------------------------------------------
;  Windows 32-bit 2000/XP/Vista/Win7 Sections
;------------------------------------------------------------------------------

[DeviceList.NTx86]
%DESCRIPTION%=DriverInstall, USB\VID_1CBE&PID_0002

[DriverInstall]
CopyFiles=DriverCopyFiles
AddReg=DriverInstall.AddReg

[DriverCopyFiles]
usbser.sys,,,0x20

[DriverInstall.AddReg]
HKR,,DevLoader,,*ntkern
HKR,,NTMPDriver,,usbser.sys
HKR,,EnumPropPages32,,"MsPorts.dll,SerialPortPropPageProvider"

[DriverInstall.Services]
AddService=usbser, 0x00000002, DriverService

[DriverService]
DisplayName=%SERVICE%
ServiceType=1
StartType=3
ErrorControl=1
ServiceBinary=%12%\usbser.sys

;------------------------------------------------------------------------------
;  Windows 64-bit Vista/Win7 Sections
;------------------------------------------------------------------------------

[DeviceList.NTamd64]
%DESCRIPTION%=DriverInstall.NTamd64, USB\VID_1CBE&PID_0002

[DriverInstall.NTamd64]
CopyFiles=DriverCopyFiles.NTamd64
AddReg=DriverInstall.NTamd64.AddReg

[DriverCopyFiles.NTamd64]
usbser.sys,,,0x20

[DriverInstall.NTamd64.AddReg]
HKR,,DevLoader,,*ntkern
HKR,,NTMPDriver,,usbser.sys
HKR,,EnumPropPages32,,"MsPorts.dll,SerialPortPropPageProvider"

[DriverInstall.NTamd64.Services]
AddService=usbser, 0x00000002, DriverService.NTamd64

[DriverService.NTamd64]
DisplayName=%SERVICE%
ServiceType=1
StartType=3
ErrorControl=1
ServiceBinary=%12%\usbser.sys

;------------------------------------------------------------------------------
;  String Definitions
;------------------------------------------------------------------------------

[Strings]
MFGNAME     = "Texas Instruments Incorporated"
DESCRIPTION = "StarterWare USB serial port"
SERVICE     = "StarterWare USB CDC serial port"

So: are there any important changes in Windows 10 related to serial drivers/serial interface/INF driver definition files? Or is this a bug in MS' USB serial driver?

Elmi
  • 5,899
  • 15
  • 72
  • 143
  • [SetCommState](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363436.aspx) sets the last error code, when it fails. What do you get back? And where is the code that fails? [mcve] required. After all, there *could* be a bug in *your* code. – IInspectable May 29 '17 at 08:05
  • IInspectable: SetCommState() returns an error complaining about invalid parameters. As said, the minimal example is GetCommState() and then do SetCommState() with exactly these parameters returned by GetCommState() - and repeateldy calling this sequence works after 2..3 tries (means SetCommState() finally accepts the parameters it previously complained about) – Elmi May 29 '17 at 08:13
  • So then, maybe your driver has issues, and the `DCB` structure returned from `GetCommState()` uses the same `XonChar` and `XoffChar`. Which does fail when passed back to `SetCommState()`. This is really too little information to go by, but an API returning an invalid parameters error code is hard to argue against. It stands to reason that the parameters *are* wrong. – IInspectable May 29 '17 at 09:33
  • IInspectable: please see my posting above, there is no special driver, I'm using the one that comes with Windows by default! usbser.sys is the one shipped by Microsoft! – Elmi May 29 '17 at 09:51
  • The *"embedded device"* surely runs a driver or at least implements the USB logic in its circuitry. Unless I'm misunderstanding your setup. – IInspectable May 29 '17 at 09:56

0 Answers0