I have a USB device I'd like to be mapped to a COM port. As everybody
seems to highly recommend to use the usbser.sys instead if possible, I
try this approach now.
So I created an INF file that registers the device.
When I plug the device to the system (1st time) it works fine. When I
unplug and replug it, it doesn't work anymore (Device Manager: Windows
cannot load the drivers reqired, Code 31).
Anybody an idea why? (See the INF file below)
Many thanks
Robin
--------- INF file -------------------------
[Version]
Signature = "$CHICAGO$"
Class = Ports
ClassGUID = {4D36E978-E325-11CE-BFC1-08002BE10318}
Provider = %manuf%
DriverVer = 08/05/2004,0.0.0.1
[DestinationDirs]
DefaultDestDir = 11,
DriverFilesDir = 12,
InfFilesDir = 17,
[ControlFlags]
ExcludeFromSelect = *
[Manufacturer]
%manuf% = manuf.Models
[manuf.Models]
%MyUSBDevice.Descr% = MyUSBDevice.Install,USB\VID_1234&PID_4321,
[MyUSBDevice.Install]
AddReg = MyUSBDevice.Install.USB
[MyUSBDevice.Install.Services]
AddService = usbser, 0x00000002, MyUSBDevice.Install.Services.Install
[MyUSBDevice.Install.Services.Install]
DisplayName = %MyUSBDevice.Descr%
ServiceType = 1 ; SERVICE_KERNEL_DRIVER
StartType = 3 ; SERVICE_DEMAND_START
ErrorControl = 1 ; SERVICE_ERROR_NORMAL
ServiceBinary = %12%\usbser.sys
[MyUSBDevice.Install.USB]
HKR,,DevLoader,,*ntkern
HKR,,NTMPDriver,,usbser.sys
;HKR,,AttachedTo,,COM5 --> recommended to not use
HKR,,EnumPropPages32,,"MsPorts.dll,SerialPortPropPageProvider"
[Strings]
manuf = "MyCompany"
MyUSBDevice.Descr = "MyCompany's Serial COM Port Emulation"
Do you handle and answer the CDC requests properly (SetLineCoding,
GetLineCoding, SetControlLineState)?
Is any user-mode app keeping the COM port open?
Leo Havmøller.
I'm sorry for that stupid question, but I'm completely new to Windows driver
development.
Thanks in advance,
Jonas Wetz
"Leo Havmųller" <l...@nospamrtx.dk> schrieb im Newsbeitrag
news:%23fnxMh5...@TK2MSFTNGP09.phx.gbl...
> Leo Havmųller.
>
>
"Jonas Wetz" <jw...@kwest.de> wrote in message
news:eZB$1C6eE...@TK2MSFTNGP12.phx.gbl...
I do not handle/answer anything. I just wrote the mentioned inf file
which references to use Microsoft usbser.sys driver. The error message
appears in the Device Manager Properties.
> Is any user-mode app keeping the COM port open?
There might be a user-mode app keeping the port open, depending on the
user. I tried with and without the app because I first thought this to
be the reason (port held open by app). But I get an in either case.
When attaching the device, starting the app and connecting the port, it
works. Then disconnecting the port, closing the app, removing the
device, re-attaching the device, starting the app again and connecting
the port, it doesn't work anymore. In this case the device manager even
tell that the device works properly...
Any idea? Thanks
Robin
The procedure as described before with proper plug/re-plug seems to fail
because of the device.
The other case (re-plug when user app is still connected to the port)
seems to fail on the Microsoft side (usbser.sys). In this case the
earlier mentioned error code 31 appears in the device manager.
So I need a solution for this case. Is it possible to do something
within the user app to prevent usbser.sys from fail (otherwise the user
must restart the PC everytime...)? Or is there a possibility with
writing a kind of driver, maybe a filter driver to usbser.sys, to handle
this?
Many thanks
Robin
You must handle and answer the mentioned requests in your USB device.
Get the USB CDC spec from
http://www.usb.org/developers/devclass_docs#approved
Leo Havmøller.
You dont need to restart the PC. Just close the application and
unplug/replug the USB device.
See new thread "User-mode handle and USB device plug/unplug".
Leo Havmøller.
I read the thread, but I think it's better to answer here.
As the device developer told me that the methods you mentioned earlier
should be handled/answered correctly, I think it's the app that needs
some improvement.
I read some help about RegisterDeviceNotification and so on. Is it right
to register for DBT_DEVTYP_PORT and then handle WM_DEVICECHANGE in the
app for DBT_DEVICEREMOVEPENDING message and DBT_DEVTYP_PORT in the
DEV_BROADCAST_HDR? Will this be enough or do I need to handle other things?
Many thanks
Robin
Thank you for any help provided
Jonas Wetz
"Alexander Grigoriev" <al...@earthlink.net> schrieb im Newsbeitrag
news:uBOWMD9e...@tk2msftngp13.phx.gbl...
> See "Include" and "Layout" INF directives. You should reference the system
> INF file which describes usbser.sys
>
> "Jonas Wetz" <jw...@kwest.de> wrote in message
> news:eZB$1C6eE...@TK2MSFTNGP12.phx.gbl...
> > I have an additional question regarding this topic. If I understand
> right,
> > I just have to create an .inf file to use the windows internal usb to
> serial
> > port emulation driver "usbser.sys". Does this mean I just have to write
> the
> > file, reference usbser.sys in this file and then I can install the
device
> > using the .inf file? Would an other application be able to handle the
> device
> > connected via usb with the same syntax used for serial ports then?
> >
> > I'm sorry for that stupid question, but I'm completely new to Windows
> driver
> > development.
> >
> > Thanks in advance,
> >
> > Jonas Wetz
> >
> >
> > "Leo Havmøller" <l...@nospamrtx.dk> schrieb im Newsbeitrag
> > news:%23fnxMh5...@TK2MSFTNGP09.phx.gbl...
> > > "> When I plug the device to the system (1st time) it works fine. When
I
> > > > unplug and replug it, it doesn't work anymore (Device Manager:
Windows
> > > > cannot load the drivers reqired, Code 31).
> > >
> > > Do you handle and answer the CDC requests properly (SetLineCoding,
> > > GetLineCoding, SetControlLineState)?
> > > Is any user-mode app keeping the COM port open?
> > >
> > > Leo Havmøller.
> > >
> > >
> >
> >
>
>
> Ok, then I have to write my own inf file and reference the inf file for
> usbser.sys with the "layout" directive, but what I exactly want is a usb to
> serial port emulation on top of the driver stack above the "normal" driver
> that I have for that device. I'm looking for a way to attach the usbser.sys
> driver at the top of the driver stack, working simply as an usb to serial
> port emulation. Is this possible that way?
>
As I understand you, that's exactly what you want. I (try to) do it the
same way. I have the INF file mentioned earlier in this thread (without
the layout.inf included) and it seems to work. What I'm trying to figure
out now ist how to handle the messages in the user-app.
Robin
"Jonas Wetz" <jw...@kwest.de> wrote in message
news:OXlTY5g...@TK2MSFTNGP11.phx.gbl...
Hope this helps precising my problem,
Jonas Wetz
"Alexander Grigoriev" <al...@earthlink.net> schrieb im Newsbeitrag
news:uvOGyWh...@TK2MSFTNGP11.phx.gbl...
If you have an underlying driver, it should work for the usbser.sys with
just an inf file, because it doesn't bother the usbser.sys whether there
is a (correctly working) underlying driver or not. But you may need
another (or the same with extension) inf file to load the underlying
driver in a correct way.