Serial driver development

Hey!

This is the first time a develops a windows driver so of course I have some major problems. I hope you guys can help me.
I have been looking at the serial example in WinDDK 7600.16385.1 and I want to make my own serial driver for a COM-port device I have.

The serial example is really helpfull but I can’t get it work. I have implemented pretty much exactly like the example for DriverEntry, SerialEvtDeviceAdd, SerialPrepareHardware and so on. What I have changed/about to changes is the IOCTLS in ioctl.c because I want to do it a bit different so it fits for my device.
When I install my driver everything works fine and my device pops up in the DeviceManager and if I check the settings in DeviceManager, it says that it uses COM3.
But the problem is that when I tries to talk to the device through COM3 (or any other COMx) it just tells me that the Port isn’t open. (Btw, I use hyperterminal for communicate with the device).

So my question is, does anyone know what initialization that must be done for open a COM-port? Or can it be my “not yet finished” ioctl part that is the problem, so if I finish it, can it work?
Like a said, this is my first driver and I don’t really understand all this yet.

Thanks in advance!

// Greger

As the com port is controlled entirely by its IOCTL interface you have to
implement that interface or you do not have a functional com port.

Mark Roddy

On Tue, Aug 3, 2010 at 9:07 AM, wrote:

> Hey!
>
> This is the first time a develops a windows driver so of course I have some
> major problems. I hope you guys can help me.
> I have been looking at the serial example in WinDDK 7600.16385.1 and I want
> to make my own serial driver for a COM-port device I have.
>
> The serial example is really helpfull but I can’t get it work. I have
> implemented pretty much exactly like the example for DriverEntry,
> SerialEvtDeviceAdd, SerialPrepareHardware and so on. What I have
> changed/about to changes is the IOCTLS in ioctl.c because I want to do it a
> bit different so it fits for my device.
> When I install my driver everything works fine and my device pops up in the
> DeviceManager and if I check the settings in DeviceManager, it says that it
> uses COM3.
> But the problem is that when I tries to talk to the device through COM3 (or
> any other COMx) it just tells me that the Port isn’t open. (Btw, I use
> hyperterminal for communicate with the device).
>
> So my question is, does anyone know what initialization that must be done
> for open a COM-port? Or can it be my “not yet finished” ioctl part that is
> the problem, so if I finish it, can it work?
> Like a said, this is my first driver and I don’t really understand all this
> yet.
>
> Thanks in advance!
>
> // Greger
>
> —
> NTDEV is sponsored by OSR
>
> For our schedule of WDF, WDM, debugging and other seminars visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer
>

On 08/03/2010 03:07 PM, xxxxx@hotmail.se wrote:

Hey!

This is the first time a develops a windows driver so of course
I have some major problems. I hope you guys can help me.

How about reading and following this piece of advice first:

http://catb.org/esr/faqs/smart-questions.html

Mark, I don’t really understand what you mean.
I do understand that all the IOCTL:s must be implemented before the COM-port works without problem. But I just don’t see why it’s not open when it says in the DeviceManager that it uses COM3. So I guess it understands and have initialized a COM-port but don’t open it?
And I don’t understand how the IOCTL:s can have with this, but I’m a no expert like some of you guys, so can anyone explain this for me?

On 08/03/2010 03:37 PM, xxxxx@hotmail.se wrote:

But I just don’t see why it’s not open when it says in the DeviceManager that it uses COM3.

This “only” means that your device driver registered itself as a serial
device and got a COM port number assigned to it. It does not mean the
device itself is functional, can be opened, etc.

How about reading up on Windows driver fundamentals (e.g. on MSDN and WHDC)?

Hyperterm opens the device AND THEN IMMEDIATELTY SENDS IT A LOT OF IOCTLS.
Either you failed to implement open/close correctly or you implemented them
correctly and can’t get past your unimplemented and absolutely required
ioctl processing.

Mark Roddy

On Tue, Aug 3, 2010 at 9:37 AM, wrote:

> Mark, I don’t really understand what you mean.
> I do understand that all the IOCTL:s must be implemented before the
> COM-port works without problem. But I just don’t see why it’s not open when
> it says in the DeviceManager that it uses COM3. So I guess it understands
> and have initialized a COM-port but don’t open it?
> And I don’t understand how the IOCTL:s can have with this, but I’m a no
> expert like some of you guys, so can anyone explain this for me?
>
> —
> NTDEV is sponsored by OSR
>
> For our schedule of WDF, WDM, debugging and other seminars visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer
>

Serial as in RS232 or USB? If it’s RS232 what does the devices specification
say for initialization? Does the cable work when using HyperTerminal on both
systems? If it does, then it most likely it is a functional modem cable and
at least makes HyperTerminal happy. If it doesn’t, then how do you have the
cable wired? Have you set DTR, received DSR? How did you set RTS, received
CTS? And of course, do you know the state of DCD and how it works with the
Rx/Tx lines?

Gary G. Little
H (952) 223-1349
C (952) 454-4629
xxxxx@comcast.net

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@hotmail.se
Sent: Tuesday, August 03, 2010 8:07 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] Serial driver development

Hey!

This is the first time a develops a windows driver so of course I have some
major problems. I hope you guys can help me.
I have been looking at the serial example in WinDDK 7600.16385.1 and I want
to make my own serial driver for a COM-port device I have.

The serial example is really helpfull but I can’t get it work. I have
implemented pretty much exactly like the example for DriverEntry,
SerialEvtDeviceAdd, SerialPrepareHardware and so on. What I have
changed/about to changes is the IOCTLS in ioctl.c because I want to do it a
bit different so it fits for my device.
When I install my driver everything works fine and my device pops up in the
DeviceManager and if I check the settings in DeviceManager, it says that it
uses COM3.
But the problem is that when I tries to talk to the device through COM3 (or
any other COMx) it just tells me that the Port isn’t open. (Btw, I use
hyperterminal for communicate with the device).

So my question is, does anyone know what initialization that must be done
for open a COM-port? Or can it be my “not yet finished” ioctl part that is
the problem, so if I finish it, can it work?
Like a said, this is my first driver and I don’t really understand all this
yet.

Thanks in advance!

// Greger


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

When you say com port device, do you mean a device at the other end of an rs232 uart (like a serial mouse) or controlling the uart itself? If it is like a serial mouse, you can use the inbox serial driver and write your driver as an upper filter, saving you a lot of pain.

d

dent from a phpne with no keynoard

-----Original Message-----
From: xxxxx@hotmail.se
Sent: August 03, 2010 6:07 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] Serial driver development

Hey!

This is the first time a develops a windows driver so of course I have some major problems. I hope you guys can help me.
I have been looking at the serial example in WinDDK 7600.16385.1 and I want to make my own serial driver for a COM-port device I have.

The serial example is really helpfull but I can’t get it work. I have implemented pretty much exactly like the example for DriverEntry, SerialEvtDeviceAdd, SerialPrepareHardware and so on. What I have changed/about to changes is the IOCTLS in ioctl.c because I want to do it a bit different so it fits for my device.
When I install my driver everything works fine and my device pops up in the DeviceManager and if I check the settings in DeviceManager, it says that it uses COM3.
But the problem is that when I tries to talk to the device through COM3 (or any other COMx) it just tells me that the Port isn’t open. (Btw, I use hyperterminal for communicate with the device).

So my question is, does anyone know what initialization that must be done for open a COM-port? Or can it be my “not yet finished” ioctl part that is the problem, so if I finish it, can it work?
Like a said, this is my first driver and I don’t really understand all this yet.

Thanks in advance!

// Greger


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

If you want your device to resemble a serial port, it *must* implement all
the DeviceIoControl functions of a serial port! Note that some may be
inappropriate (e.g., if your device does not have a variable data rate, you
will “ignore” the set-baud-rate requests, and I put “ignore” in quotes
because you have to (a) IoCompleteRequest the IRP with a STATUS_SUCCESS (b)
retain the dummy baud rate value to be returned on a query, *even though it
has no meaning*. Otherwise, a program like HyperTerminal assumes that if
anything fails (for example, setting inter-character timeouts) that the port
is non-responsive, and it will probably close it and report an error.

If you want to *add* functionality, you are free to do so, providing that
failure to use that functionality does not affect the ability of your
COM-like port to actually work in a COM-port context, which apparently is
what you want to do.

You have suggested (but not actually said) that you have changed some of the
functionality. You have to *honor* all the requests that come down, even if
it means maintaining useless information to be returned on a query for that
information. You can’t simply reject something you don’t support if it is
one of the (I think 44, if I recall correctly) required IOCTLs for a serial
port.

You have also not suggested that you wrote a little test program that opened
the port, wrote something to it, and closed the port (or read something from
it, or just tried to open and close it). Instead, you go to full-blown
HyperTerminal, which probably expects *perfect* conformance with the
required IOCTLs. I suggest building small test programs and testing a
feature at a time; your testing methodology of testing all features
simultaneously is not a good testing strategy.

You can’t implement it “pretty much exactly”, you have no choice but to
implement it *exactly*. At least at the upper edge, where the IRPs are
coming through; what you actually do to the device is your business, as long
as the interface remains identical at the upper edge of the driver.

I actually had a client that had a serial port filter driver that talked
across the network to another machine and used its serial port, sort of a
“redirector”. The filename was of the form

\.COMn\192.168.168.4\COMm

Where COMn was the local serial port and COMm was the serial port to use on
the remote machine, shown here as 192.168.168.4. I had nothing to do with
the coding of this, in fact, all I had to do was interface my application to
it. They bought it from someone else. We used it to connect a serial port
device to the remote computer’s serial port. In this case, it sent the
baud-rate-change as an OOB packet to the remote machine, which would change
the baud rate on its local serial port. But that was six years ago, and
I’ve forgotten who the vendor was (the machines on which I was running it
are long since retired).

But your description lacks critical information about what you changed, how
you changed it, etc., making it impossible guess what is going wrong.

Write a little test program. All it does is open and close the device.
Then try each feature of the serial port, one at a time, carefully checking
for what is returned. When you have a test harness that lets you test every
single feature individually, and you have shown that you have tested every
feature individually, ONLY THEN do you throw some massive program like
HyperTerminal at it. Using DbgPrint or WPP or even (and this is not a good
idea) event log output to trace what is going on, particularly for all error
returns, would be crucial.
joe

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@hotmail.se
Sent: Tuesday, August 03, 2010 9:07 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] Serial driver development

Hey!

This is the first time a develops a windows driver so of course I have some
major problems. I hope you guys can help me.
I have been looking at the serial example in WinDDK 7600.16385.1 and I want
to make my own serial driver for a COM-port device I have.

The serial example is really helpfull but I can’t get it work. I have
implemented pretty much exactly like the example for DriverEntry,
SerialEvtDeviceAdd, SerialPrepareHardware and so on. What I have
changed/about to changes is the IOCTLS in ioctl.c because I want to do it a
bit different so it fits for my device.
When I install my driver everything works fine and my device pops up in the
DeviceManager and if I check the settings in DeviceManager, it says that it
uses COM3.
But the problem is that when I tries to talk to the device through COM3 (or
any other COMx) it just tells me that the Port isn’t open. (Btw, I use
hyperterminal for communicate with the device).

So my question is, does anyone know what initialization that must be done
for open a COM-port? Or can it be my “not yet finished” ioctl part that is
the problem, so if I finish it, can it work?
Like a said, this is my first driver and I don’t really understand all this
yet.

Thanks in advance!

// Greger


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer


This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.