Does anyone know the following issue?
My virtual USB modem driver will run the IOCTL_SERIAL_*** code list twice in initialization. why?
I’m making some improvement on this driver. But now it run run the IOCTL_SERIAL_*** code list many time, and it can now work well, I’m debugging it.
thank you very much.
huaping
xxxxx@gmail.com wrote:
Does anyone know the following issue?
My virtual USB modem driver will run the IOCTL_SERIAL_*** code list twice in initialization. why?
I’m making some improvement on this driver. But now it run run the IOCTL_SERIAL_*** code list many time, and it can now work well, I’m debugging it.
Why is this a problem? You should be able to respond to these IOCTL at
any time in any order.
–
Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.
Yes, I need to response these IOCTL, but I think one time is enough, if everything is ok.
I find other modem driver only run this IOCTL list one time.
And what I 'm debugging is I received the IOCTL_SERIAL_PURGE message. I think there is any wrong in my driver.
huaping jiang wrote:
My virtual USB modem driver will run the IOCTL_SERIAL_*** code
list twice in initialization. why?
I would post an annotated list of the exact IOCTLs that you’re receiving, and during what point of the “initialization” process you’re receiving them.
If you are getting I/O in a different order than established known good drivers (such as, say, usbser), then you actually are probably doing something wrong.
Hi Chris
Yes, there should be some code that don’t work correctly.
But I can not find the cause. I just find after I completed several read IRP in initialization, I received the IOCTL_SERIAL_PURGE message.
thanks
huaping
huaping jiang wrote:
Yes, there should be some code that don’t work correctly. But I can
not find the cause. I just find after I completed several read IRP in
initialization, I received the IOCTL_SERIAL_PURGE message.
Why do you think receiving IOCTL_SERIAL_PURGE means you did something wrong? It doesn’t.
There likely is something wrong, but you haven’t posted enough information in order for anyone to help you.
Hi Chris
the IOCTL list is following:
1.IOCTL_SERIAL_SET_DTR
2.IOCTL_SERIAL_GET_PROPERTIES
3.IOCTL_SERIAL_GET_BAUD_RATE
4.IOCTL_SERIAL_GET_LINE_CONTROL
5.IOCTL_SERIAL_GET_CHARS
6.IOCTL_SERIAL_GET_HANDFLOW
7.IOCTL_SERIAL_GET_BAUD_RATE
8.IOCTL_SERIAL_SET_DTR
9.IOCTL_SERIAL_SET_LINE_CONTROL
10.IOCTL_SERIAL_SET_CHARS
11.IOCTL_SERIAL_SET_HANDFLOW
12.IRP_MN_QUERY_DEVICE_RELATIONS--------
13.IOCTL_SERIAL_PURGE
14.IOCTL_SERIAL_CLEAR_STATS
15.IOCTL_SERIAL_PURGE
16.IOCTL_SERIAL_SET_TIMEOUTS
17.IOCTL_SERIAL_GET_COMMSTATUS
18.IOCTL_SERIAL_GET_LINE_CONTROL
19.IOCTL_SERIAL_GET_CHARS
20.IOCTL_SERIAL_GET_HANDFLOW
21.IOCTL_SERIAL_GET_BAUD_RATE
22.IOCTL_SERIAL_SET_RTS
23.IOCTL_SERIAL_SET_DTR
24.IOCTL_SERIAL_SET_LINE_CONTROL
25.IOCTL_SERIAL_SET_CHARS
26.IOCTL_SERIAL_SET_HANDFLOW
27.IOCTL_SERIAL_SET_DTR
28.IOCTL_SERIAL_GET_MODEMSTATUS
type AT in hyper terminal.
29.IRP_MJ_WRITE (0x41 0x54 0x5A 0x45 0x30 0x51 0x30 0x56 0x31 0xD)
30.complete IRP_MJ_READ with 1 bytes
31.IOCTL_SERIAL_GET_COMMSTATUS (return 5 bytes)
32.IRP_MJ_READ (with 5 bytes)
33.complete IRP_MJ_READ withe 5 bytes
34.IOCTL_SERIAL_GET_COMMSTATUS (return 0)
35.IRP_MJ_READ with 1byte
36.IRP_MJ_WRITE (with0x41 0x54 0x45 0x30 0x51 0x30 0x56 0x31 0x26 0x46 0x26 0x44 0x32 0x26 0x43 0x31 0x53 0x30 0x3D 0x30 0xD)
37.coplete IRP_MJ_READ (with 1 byte)
38.IOCTL_SERIAL_GET_COMMSTATUS (return 5 bytes) 6 bytes =0xD 0xA 0x4F 0x4B 0xD 0xA==OK
39.IRP_MJ_READ AND complete read.
40.IOCTL_SERIAL_GET_COMMSTATUS (return 0)
41.IRP_MJ_WRITE 0x41 0x54 0x53 0x37 0x3D 0x36 0x30 0x20 0x58 0x34 0xD
42.complet read OK. omit the IRP_MJ_READ list
43.write 32 bytes 0x61 0x74 0x2B 0x63 0x72 0x6D 0x3D 0x31 0x3B 0x2B 0x63 0x6D 0x75 0x78 0x3D 0x31 0x3B 0x2B 0x63 0x70 0x73 0x3D 0x33 0x33 0x3B 0x2B 0x63 0x74 0x61 0x3D 0x30 0xD
44.receive these 32 bytes and ok(6bytes). compete 2 IRP_MJ_READ (len is 1 and 37 bytes)
45.IOCTL_SERIAL_GET_COMMSTATUS (return with 1byte)
46.IRP_MJ_READ with 1byte.
47.IOCTL_SERIAL_PURGE (mask = 0x5)
48.IOCTL_SERIAL_GET_BAUD_RATE
49.IOCTL_SERIAL_GET_LINE_CONTROL
50.IOCTL_SERIAL_GET_CHARS
51.IOCTL_SERIAL_GET_HANDFLOW
52.IOCTL_SERIAL_GET_BAUD_RATE
53.IOCTL_SERIAL_GET_LINE_CONTROL
54.IOCTL_SERIAL_GET_CHARS
…
now I think there is something wrong
thank you very much.
huaping jiang wrote:
16.IOCTL_SERIAL_SET_TIMEOUTS
17.IOCTL_SERIAL_GET_COMMSTATUS
Right after these two IOCTLs, I get a one-byte read which I pend immediately because my buffer is empty. There is a 20ms interval timeout on it, but otherwise no timeout. (Are you handling interval timeouts (correctly))? You don’t show a read until step 32, which is somewhat different. Otherwise my steps 1-28 are the same as yours.
47.IOCTL_SERIAL_PURGE (mask = 0x5)
My mask here is 0x2. Also, after these I get SET_WAIT_MASK and WAIT_ON_MASK, but you don’t give those in your listing.
Are you handling GET/SET_CHARS and GET/SET_HANDFLOW? I also get a call to GET_QUEUE_SIZE (and you don’t seem to), but that probably doesn’t matter.
Hi Chris
you are right there is an 1 byte READ IRP after 17, and I pend it, and complete it in 30.
I haven’t handled the interval timer now ,because I don’t know how to set the interval timer, because every URB I will received many bytes’ data, and reset the interval timer at that time(I mean when my URB returned with data)?
ok, I will try to handle the interval timer. I have set the total timer.
the following the PURGE list
13.IOCTL_SERIAL_PURGE(mask is 0x3)
15.IOCTL_SERIAL_PURGE (mask is 0x2)
47.IOCTL_SERIAL_PURGE (mask is 0x5) means purge TXABORT and TXCLEAR.
do you think there is something wrong on IRP_MJ_WRITE?
thank you very much.
Hi Chris
I find a thing that is. I use my write completion rouine is called after URB read completion.(I use system thread (workitem) to read data from USB, so there is an URB read completion used to copy read data into the read buffer, if there is pending reads, I will try to complete them.)
Do you think the last PURGE (mask is 0x5) is caused by the delayed write completion?
thanks
huaping
huaping jiang wrote:
I haven’t handled the interval timer now ,because I don’t know how to
set the interval timer, because every URB I will received many bytes’
data, and reset the interval timer at that time(I mean when my URB
returned with data)?
Well, I’ve got some bad news for you. Your driver will never really work correctly if you don’t properly implement the MS serial specification. This includes all the serial timeout semantics[1], all the serial IOCTLs[2], and all the event flags[3] (including those that don’t really make sense for a USB modem – for example, the EV_TXEMPTY event, even if you don’t have a transmit queue).
Remember when your driver didn’t work in Winfax because you didn’t implement IOCTL_SERIAL_IMMEDIATE_CHAR? You’ve got plenty more bugs like that lurking until you get everything right.
I don’t really understand what you mean about you “don’t know how to set the interval timer”, since you’re given the exact value to use in IOCTL_SERIAL_SET_COMMTIMEOUTS. Maybe you mean you don’t know how or when to start or persist the timer. The inbox serial driver source is included with the WDK. If you’re unsure how to proceed, check there.
[1] http://msdn2.microsoft.com/en-us/library/aa363190(VS.85).aspx
[2] http://msdn2.microsoft.com/en-us/library/ms800933.aspx
[3] http://msdn2.microsoft.com/en-us/library/aa363479(VS.85).aspx
huaping jiang wrote:
I find a thing that is. I use my write completion rouine is called after
URB read completion.(I use system thread (workitem) to read data
from USB, so there is an URB read completion used to copy read data
into the read buffer, if there is pending reads, I will try to complete
them.) Do you think the last PURGE (mask is 0x5) is caused by the
delayed write completion?
I have no idea. You’re saying you’re sharing the completion routine for both URB reads and writes? I wouldn’t do that, mostly because the processing required afterward is totally different for each (read completion you have to walk the list of pending reads and take any necessary action, write completion you may need to continue staged I/O or fire a serial event, etc.)
At this point I wouldn’t worry about why you’re getting some PURGE request (if only because you/I/anyone don’t have the TAPI/DUN source code and you’ll never know why it’s doing what it’s doing). Judging by what you’ve said so far about your driver, you have far more serious problems to address.
Hi Chris
Thank you very much.
I need to add the
huaping Jiang