Interesting Problem

Hi

I have a USB-to-Serial(RS232) Adapter attached to my PC. The name of the USB driver that is loaded is ser2pl.sys.

It exposes a COM (COM5 in my case) interface so that my application can use the GetCommModemStatus() to get the status of the DCD(RLSD).

Now I want to do this polling in kernel mode since I want to monitor the DCD changes in real time.

My first thought was to write a driver which inturn would send ioctl messages periodically to this USB driver to get the modem status. But i dont know whether this is technically feasible, and if so, how to accomplish it.

Any pointers on this ? Also if there is any other better way to accomplish real-time polling ?

Many Thanks
Kiran


Sneak preview the all-new Yahoo.com. It’s not radically different. Just radically better.

There is nothing particularly realtime about a thread polling in the kernel
vs a thread polling in user mode. Threads are threads, NT is not a real time
OS, and kernel mode does not provide any special thread runtime attributes
with respect to scheduling. That said, your user mode polling can of course
use standard NT process/thread priority mechanisms to give you a response
time that should work within your requirements.

=====================
Mark Roddy DDK MVP
Windows 2003/XP/2000 Consulting
Hollis Technology Solutions 603-321-1032
www.hollistech.com


From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Kiran Bacche
Sent: Saturday, June 17, 2006 5:07 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] Interesting Problem

Hi

I have a USB-to-Serial(RS232) Adapter attached to my PC. The name of the
USB driver that is loaded is ser2pl.sys.

It exposes a COM (COM5 in my case) interface so that my application can use
the GetCommModemStatus() to get the status of the DCD(RLSD).

Now I want to do this polling in kernel mode since I want to monitor the DCD
changes in real time.

My first thought was to write a driver which inturn would send ioctl
messages periodically to this USB driver to get the modem status. But i dont
know whether this is technically feasible, and if so, how to accomplish it.

Any pointers on this ? Also if there is any other better way to accomplish
real-time polling ?

Many Thanks
Kiran


Sneak preview the all-new
http: Yahoo.com.
It’s not radically different. Just radically better. — Questions? First
check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256
To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer</http:>

Yes, a kernel driver can open the com port and send ioctls (almost) like usermode app.
But the question is why write a kernel driver when you can do the same
from usermode app or service?
( a hint: usermode app *can* have a realtime priority ).

–PA

“Kiran Bacche” wrote in message news:xxxxx@ntdev…
> Hi
>
> I have a USB-to-Serial(RS232) Adapter attached to my PC. The name of the USB driver that is loaded is ser2pl.sys.
>
> It exposes a COM (COM5 in my case) interface so that my application can use the GetCommModemStatus() to get the status of the
> DCD(RLSD).
>
> Now I want to do this polling in kernel mode since I want to monitor the DCD changes in real time.
>
> My first thought was to write a driver which inturn would send ioctl messages periodically to this USB driver to get the
> modem status. But i dont know whether this is technically feasible, and if so, how to accomplish it.
>
> Any pointers on this ? Also if there is any other better way to accomplish real-time polling ?
>
> Many Thanks
> Kiran
>
>
>
> ---------------------------------
> Sneak preview the all-new Yahoo.com. It’s not radically different. Just radically better.

Yes, my kernel mode polling did not help. Also I tried setting the application priority to “real-time” via Task manager interface. But still it is not really “real-time”.
As a final resort, Im planning to write my own USB driver replacing the ser2pl.sys USB driver that came with the USB-to-serial adapter.

As soon as the DCD changes state, the USB-2-Serial adapter sends a USB interrupt transfer packet. This is behaviour of the device.

I think the windows USB subsystem would get this packet asynchronously (via interrupt) and then disptach it asynchronously to the appropriate upper device driver depending on the device id. Right ?

Now can somebody point me to a sample USB device driver with callbacks invoked when “interrupt transfer packets” arrive from a USB device ?

This would avoid polling entirely.

Many Thaks
Kiran

“Pavel A.” wrote:
Yes, a kernel driver can open the com port and send ioctls (almost) like usermode app.
But the question is why write a kernel driver when you can do the same
from usermode app or service?
( a hint: usermode app can have a realtime priority ).

–PA

“Kiran Bacche” wrote in message news:xxxxx@ntdev…
> Hi
>
> I have a USB-to-Serial(RS232) Adapter attached to my PC. The name of the USB driver that is loaded is ser2pl.sys.
>
> It exposes a COM (COM5 in my case) interface so that my application can use the GetCommModemStatus() to get the status of the
> DCD(RLSD).
>
> Now I want to do this polling in kernel mode since I want to monitor the DCD changes in real time.
>
> My first thought was to write a driver which inturn would send ioctl messages periodically to this USB driver to get the
> modem status. But i dont know whether this is technically feasible, and if so, how to accomplish it.
>
> Any pointers on this ? Also if there is any other better way to accomplish real-time polling ?
>
> Many Thanks
> Kiran
>
>
>
> ---------------------------------
> Sneak preview the all-new Yahoo.com. It’s not radically different. Just radically better.


Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256

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

---------------------------------
Do you Yahoo!?
Next-gen email? Have it all with the all-new Yahoo! Mail Beta.

---------------------------------
Sneak preview the all-new Yahoo.com. It’s not radically different. Just radically better.

It is more like you park URBs with the USB driver, and when the device
transfers an interrupt packet your driver gets called with one of your URBs
completed. See any of the USB samples for hints.

But before you go off an rewrite a serial driver - are you sure that
IOCTL_SERIAL_SET_WAIT_MASK and friends won’t do what you need?

=====================
Mark Roddy DDK MVP
Windows 2003/XP/2000 Consulting
Hollis Technology Solutions 603-321-1032
www.hollistech.com


From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Kiran Bacche
Sent: Sunday, June 18, 2006 11:57 AM
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] Interesting Problem

Yes, my kernel mode polling did not help. Also I tried setting the
application priority to “real-time” via Task manager interface. But still it
is not really “real-time”.
As a final resort, Im planning to write my own USB driver replacing the
ser2pl.sys USB driver that came with the USB-to-serial adapter.

As soon as the DCD changes state, the USB-2-Serial adapter sends a USB
interrupt transfer packet. This is behaviour of the device.

I think the windows USB subsystem would get this packet asynchronously (via
interrupt) and then disptach it asynchronously to the appropriate upper
device driver depending on the device id. Right ?

Now can somebody point me to a sample USB device driver with callbacks
invoked when “interrupt transfer packets” arrive from a USB device ?

This would avoid polling entirely.

Many Thaks
Kiran

“Pavel A.” wrote:

Yes, a kernel driver can open the com port and send ioctls (almost) like
usermode app.
But the question is why write a kernel driver when you can do the same
from usermode app or service?
( a hint: usermode app can have a realtime priority ).

–PA

“Kiran Bacche” wrote in message news:xxxxx@ntdev…
> Hi
>
> I have a USB-to-Serial(RS232) Adapter attached to my PC. The name of the
USB driver that is loaded is ser2pl.sys.
>
> It exposes a COM (COM5 in my case) interface so that my application can
use the GetCommModemStatus() to get the status of the
> DCD(RLSD).
>
> Now I want to do this polling in kernel mode since I want to monitor the
DCD changes in real time.
>
> My first thought was to write a driver which inturn would send ioctl
messages periodically to this USB driver to get the
> modem status. But i dont know whether this is technically feasible, and if
so, how to accomplish it.
>
> Any pointers on this ? Also if there is any other better way to accomplish
real-time polling ?
>
> Many Thanks
> Kiran
>
>
>
> ---------------------------------
> Sneak preview the all-new Yahoo.com. It’s not radically different. Just
radically better.


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

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



Do you Yahoo!?
Next-gen email? Have it all with the all-new
http:aisers> Yahoo! Mail Beta.



Sneak preview the all-new
http: Yahoo.com.
It’s not radically different. Just radically better. — Questions? First
check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256
To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer</http:></http:>

On Sun, Jun 18, 2006 at 08:56:31AM -0700, Kiran Bacche wrote:

Yes, my kernel mode polling did not help. Also I tried setting the
application priority to “real-time” via Task manager interface. But
still it is not really “real-time”.

And it never will be, unfortunately…

As a final resort, Im planning to write my own USB driver replacing the
ser2pl.sys USB driver that came with the USB-to-serial adapter.

As soon as the DCD changes state, the USB-2-Serial adapter sends a USB
interrupt transfer packet. This is behaviour of the device.

Well, not really… I’ll explain in a moment.

I think the windows USB subsystem would get this packet asynchronously
(via interrupt) and then disptach it asynchronously to the appropriate
upper device driver depending on the device id. Right ?

No. This is a common misunderstanding, and it is one which derives directly
from the somewhat misleading term “interrupt pipe”.

There is no such thing as an asynchronous transfer in USB, and an interrupt
pipe does not actually interrupt the processor. USB is ENTIRELY a host-
driven protocol. A device is not permitted to send anything unless and
until the host has asked it for data.

In the case of an interrupt pipe, the host is only going to ask the
device once every N frames, where N is specified in the device’s
descriptors. Further, the host will not send a request at all unless
a driver has queued up a read request by the time the frame starts. If
there is no read request, then the device will never get the chance to
send.

Now can somebody point me to a sample USB device driver with
callbacks invoked when “interrupt transfer packets” arrive from a USB
device ?

USB does not work that way. You have to keep sending read requests in
order for the device to send. When the driver gets the packet, it has
to turn right around and submit another read URB so the host controller
will send an IN token to the device.

So, as you can see, these USB-to-RS232 converters are NOT real-time in
the traditional sense. You probably won’t be able to do much better
than your user-mode app.