>I guess I must (like all the
other serial IOCTL requests) transform it to some kind of CDC class request.
But what is the CDC class request I should transform it to? I can’t find any
feasible request in the usb CDC specification. Or what should I do with it?
Any suggestion is welcome!
I have a problem like this too.
For me it’s the IOCTL_SERIAL_PURGE I don’t understand what to do with. I can’t find any good request in the usb-spec or CDC-spec to translate it to. This far I have received the inputbuffer and checked which purge mask it has.
But now I must understand which usb request to create (or what else I should do?).
Thankfull for any help! 
xxxxx@tjelvar.org wrote:
> I guess I must (like all the
> other serial IOCTL requests) transform it to some kind of CDC class request.
> But what is the CDC class request I should transform it to? I can’t find any
> feasible request in the usb CDC specification. Or what should I do with it?
> Any suggestion is welcome!
I have a problem like this too.
For me it’s the IOCTL_SERIAL_PURGE I don’t understand what to do with. I can’t find any good request in the usb-spec or CDC-spec to translate it to. This far I have received the inputbuffer and checked which purge mask it has.
But now I must understand which usb request to create (or what else I should do?).
Well, you have to figure this out. That’s your job as a driver writer.
Think about what the request does. What’s the equivalent operation with
a USB device? If it were me, I’d just cancel any outstanding URBs in
the direction of the purge request. I don’t know what else you could do.
Also note, however, that there are some serial ioctls that no one ever
uses. So, if you find an ioctl you don’t know how to handle, one
alternative is to fail the ioctl with STATUS_NOT_IMPLEMENTED, and see
what doesn’t work.
–
Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.
Tim Roberts wrote:
Also note, however, that there are some serial ioctls that no
one ever uses.
Ha ha, that’s what you think…
Frans Handel wrote:
For me it’s the IOCTL_SERIAL_PURGE I don’t understand what to
do with. I can’t find any good request in the usb-spec or CDC-spec
to translate it to.
Not every IOCTL is “translated” to an URB. Some alter the state of your driver, this is probably one of them.
>If it were me, I’d just cancel any outstanding URBs in
the direction of the purge request.
Thanks Tim and Chris, this sounds very logic after all. 
But…
I still have one more question about this.
The IOCTL_SERIAL_PURGE request have flags that says:
SERIAL_PURGE_RXABORT
Purges all read requests.
SERIAL_PURGE_RXCLEAR
Purges the receive buffer, if one exists.
SERIAL_PURGE_TXABORT
Purges all write requests.
SERIAL_PURGE_TXCLEAR
Purges the write buffer, if one exists.
And cancel all outstanding requests seems very good for the RXABORT and TXABORT case. But what about RXCLEAR and TXCLEAR. I don’t think my driver uses these buffers but I’m not entirely sure. And if it doesn’t use it, should I just skip it and do what?
Thanks for helping a beginner like me! 
xxxxx@tjelvar.org wrote:
I still have one more question about this.
The IOCTL_SERIAL_PURGE request have flags that says:
SERIAL_PURGE_RXABORT
Purges all read requests.
SERIAL_PURGE_RXCLEAR
Purges the receive buffer, if one exists.
SERIAL_PURGE_TXABORT
Purges all write requests.
SERIAL_PURGE_TXCLEAR
Purges the write buffer, if one exists.
And cancel all outstanding requests seems very good for the RXABORT and TXABORT case. But what about RXCLEAR and TXCLEAR. I don’t think my driver uses these buffers but I’m not entirely sure. And if it doesn’t use it, should I just skip it and do what?
What would you guess? If a client asks you to clear your receive buffer
(if one exists), and none exists for your device, then you can
adequately handle the request by doing nothing. Just complete the
request with “success”.
–
Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.
Frans Handel wrote:
But what about RXCLEAR and TXCLEAR. I don’t think my driver
uses these buffers but I’m not entirely sure.
You don’t “think” you have buffers like that? Well, then I have two pieces of advice for you:
-
Find out, because it’s your driver.
-
If your driver doesn’t have a receive buffer, it will never work properly as a Windows serial port.
Chris, I do uses the buffers that can get access to by WdfRequestRetrieveInputBuffer and WdfRequestRetrieveOutputBuffer, is this the buffers you mean?
Or must I use some other selfdeclared buffer to get the serial port work properly?
I’m sorry that I ask this stupied questions (atleast stupied from your point of view). But I’m a totaly beginner with driver development. I’m not getting payed for doing this, I’m just want to learn. And I guess all of you guys have been in my situation some time ago. Propably a long long long time ago. 
So I’m very happy for every help I can get but I also understand that you might think this is a waste of your time to help me. But thanks any way for the help I got so far and any further help!
Frans Handel wrote:
Chris, I do uses the buffers that can get access to by
WdfRequestRetrieveInputBuffer and
WdfRequestRetrieveOutputBuffer, is this the buffers you
mean?
No, it is not.
Or must I use some other selfdeclared buffer to get the
serial port work properly?
It sounds like you need to study the serial port interface[1]. What are you trying to do?
[1]
http://msdn.microsoft.com/en-us/library/ff547466(VS.85).aspx
Thanks for the link Chris. You are indeed right that I must study this more. But my problem is to understand it. 
Like I said, this is totaly new for me. I’m acctually a web developer with focus on internet security but have done some other kind of programming before too. But this is so much different from my other work areas.
I just want to learn a bit about driver development, I won’t be a 100% driver developer but I think it is really good (and fun) to learn new stuff from other areas.
I have written a few small drivers for some devices I had home. Like a basic Usb-driver which I developt from the osrusbfx2 example.
And now I found a old modem which uses usbser.sys. So I just tries to write my own driver for it instead of usbser.sys. And of course I do understand that this is a major project and that I probably never gone get it totaly right and stable. But I want to try for the sake of learning. 
I will also try to take one or two OSR seminars this autumn when I have some more time free.
So thanks for your help, it is priceless for my learning!
Frans Handel wrote:
And now I found a old modem which uses usbser.sys. So I
just tries to write my own driver for it instead of usbser.sys.
Going from the osrusbfx2 sample to a usbser replacement is a huge jump. Not only are you responsible for understanding CDC ACM but also the serial port spec which is very complicated for someone new to pick up. There’s actually plenty of stuff that is totally undocumented which you would need to do correctly as well. Overall, a lot of grief for not much useful stuff learned.
>Overall, a lot of grief for not much useful stuff learned.
Ok, I guess you’re right about that Chris. But I still want to try.
So now I’m back with another question, if somebody still wants to help me.
I’m working on translating IOCTL_SERIAL_SET_LINE_CONTROL to the corresponding USB request.
I have studied the CDC spec. for a while and I think that that IOCTL should be transformed into a SetLineCoding request for the USB. First of all, anyone know if this is correct?
Second, if so, I have transformed the information in the inputbuffer into the information like a specified Line Coding structure as the CDC spec explains it. (Right now I have just put the bit-pattern in a ULONGLONG variable because I don’t understand how to use it).
Now I want send it down somehow. And if I don’t missunderstands it I should format a control transfer request for the usb and send my information with it. Is that right?
But I don’t understand how to send my lineControl with a control transfer request, I guess that I must attach it as the TransferMemory in the Control transfer request. But if so, I don’t understand how to do it, because it must be a WDFMEMORY handle, and I can’t understand how to transform my information into the that.
Anyone can explain this for a confused newbe? 