USB 2 serial UPPER filter driver

hi…
i am developing a usb2serial filter driver(virtual com port) which
will sit on top of the USB functional device driver by using UMDF tech…in
usb functional driver i am inter facing with the device by
hr = m_FxDevice->CreateDeviceInterface(&GUID_DEVINTERFACE_OSRUSBFX2,
NULL);
hr = m_FxDevice->AssignDeviceInterfaceState(&GUID_DEVINTERFACE_OSRUSBFX2,
NULL,
TRUE);

and this filter driver has to be appeared as COM2 for my PC for that i
thought to us e

m_FxDevice->CreateDeviceInterface(&GUID_DEVINTERFACE_COMPORT,NUL
m_FxDevice->AssignDeviceInterfaceState(&GUID_DEVINTERFACE_COMPORT,NULL,TRUE);
if i add this code in filter driver cofigure() function will it work as
COM2 for my pc
or anything i would have to use…and canu tell me how to cofigure the
baudrate n all while sending n receiving the data if u had any idea…

for ur understanding my requiremnet:
we had one softare in PC which will detect only COM ports…earlier this pc
was talking with the device by rs232…now the device is upgraded to
USB…and we r not supposed to do any chnges in software of PC…so we thoght
that we will develop a driver i.e USB 2 serial filter driver acts as a
virtual com port for PC…
it will sit on top of USB functional driver which will talk with the device
correctly

sukumar gudugunta wrote:

i am developing a usb2serial filter driver(virtual com port) which will
sit on top of the USB functional device driver by using UMDF tech.

You say you’re “interfacing with the device” by using the OSRUSBFX2 GUID. Well, COM ports are exclusive open, so don’t think you’ll be feeding your virtual COM port data from one end and consuming it on the COM port device interface from the other.

Further, you say you’re writing a UMDF upper filter to a UMDF function driver that you own yourself. Why not just combine the two? (note that I’m not sure it’s actually possible to do a virtual COM port in UMDF. You certainly couldn’t do it for a modem, since UMDF must be at the top of the stack and a modem function driver sits below Modem.sys…)

if i add this code in filter driver cofigure() function will it work as
COM2 for my pc or anything i would have to use

No. You registered the COM port device interface, but you’re saying an application is going to look for the name “COM2”. See the problem?

No. You registered the COM port device interface, but you’re saying an
application is going to look for the name “COM2”. See the problem?
here i wil aceess the comdatabase functions to get the name as com2 it’s ok…
we r developing the functional driver to talk with the device …n implementing the filter driver to show USB device as COM port of PC…for that i thouhu to implement…
m_FxDevice->CreateDeviceInterface(&GUID_DEVINTERFACE_COMPORT,NUL
comdatabase functions will come here
m_FxDevice->AssignDeviceInterfaceState(&GUID_DEVINTERFACE_COMPORT,NULL,TRUE);
in filter driver cofigure() function
if iwas thinking in wrong way can anyone suggest me to solve this problem…

Do you want to write a generic serial upper filter that makes it look like a com port to any application? Or do you want to only support this application.

Basically, do you need a fully generic and fully implemented serial port solution or a solution that only implements enough of serial to get your specific app working. The reason I ask is that for a generic solution, UMDF is not the right answer right now (but will be in a future release) because you cannot write to the SERIALCOMM key nor do you see all of the necessary IRPs (like IRP_MJ_FLUSH_BUFFERS). If your app does not flush nor look in the SERIALCOMM key, the limitations of UMDF may not be important and you can possibly get it to work.

OTOH, you can get access to everything you need from a KMDF driver, but you will then be in kernel mode…

d

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@lntemsys.com
Sent: Wednesday, June 25, 2008 1:38 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] USB 2 serial UPPER filter driver

hi…
i am developing a usb2serial filter driver(virtual com port) which
will sit on top of the USB functional device driver by using UMDF tech…in
usb functional driver i am inter facing with the device by
hr = m_FxDevice->CreateDeviceInterface(&GUID_DEVINTERFACE_OSRUSBFX2,
NULL);
hr = m_FxDevice->AssignDeviceInterfaceState(&GUID_DEVINTERFACE_OSRUSBFX2,
NULL,
TRUE);

and this filter driver has to be appeared as COM2 for my PC for that i
thought to us e

m_FxDevice->CreateDeviceInterface(&GUID_DEVINTERFACE_COMPORT,NUL
m_FxDevice->AssignDeviceInterfaceState(&GUID_DEVINTERFACE_COMPORT,NULL,TRUE);
if i add this code in filter driver cofigure() function will it work as
COM2 for my pc
or anything i would have to use…and canu tell me how to cofigure the
baudrate n all while sending n receiving the data if u had any idea…

for ur understanding my requiremnet:
we had one softare in PC which will detect only COM ports…earlier this pc
was talking with the device by rs232…now the device is upgraded to
USB…and we r not supposed to do any chnges in software of PC…so we thoght
that we will develop a driver i.e USB 2 serial filter driver acts as a
virtual com port for PC…
it will sit on top of USB functional driver which will talk with the device
correctly


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

thanks for ur response…
just ihad gone through the KMDf serial code it is implemnted for full fledze serial device…i thought UMDF can do why becz in umdf we cant write the port name to HKLM\HARDWARE\DEVICEMAP\SERIALCOMM(which can be possible by WDM n kmdf).
but if we install our device under the ports class and use the PortName
assigned to our driver createsymboliclin k then my port can be identified as a virtual port for PC.
but i am in confusion that where to implment the following code

m_FxDevice->CreateDeviceInterface(&GUID_DEVINTERFACE_COMPORT,NULL);
m_FxDevice->CreateSymbolicLink(L"\DosDevices\Global\COM2");
m_FxDevice->AssignDeviceInterfaceState(&GUID_DEVINTERFACE_COMPORT,NULL,TRUE);
in func driver it is interfacing with the device GUID…i thought to implemnt it in FILterdriver…m i right? or this problem can be solved if we combine the two drivers…if i am totally in wrong way can u suggest me how to reach my requirement and one more thing i add above code in skeleton sample code cofiguration function n compiled but it is giving the error as unresolved external error why is ths?
c:\winddk\6000\src\umdf\skeleton\device.obj : error LNK2001: unresolved external symbol _GUID_DEVINTERFACE_COMPORT
c:\winddk\6000\src\umdf\skeleton\objfre_wlh_x86\i386\umdfskeleton.dll : error LNK1120: 1 unresolved externals
thanks in advance…

sukumar gudugunta wrote:

but if we install our device under the ports class and use the PortName
assigned to our driver createsymboliclin k then my port can be identified
as a virtual port for PC.

That’s the problem. You can’t “use” PortName because, as Doron said, you can’t write it out to the SERIALCOMM key. Therefore, no one can discover your port’s existence, at least by enumerating all the values in SERIALCOMM.

Now, as an alternative, you mention that someone can pull the symbolic link to your device interface, and then use SetupDi()… to find the port name, but why bother at that point? If you have the symbolic link, why not just open it that way?

The point is – you can’t do a “full fledged” (i.e. that will be 100% compatible with every application) COM port in UMDF because you can’t handle FLUSH_BUFFERS and you can’t touch SERIALCOMM. You’ve said many times that you are replacing an “existing” RS-232 device and that the existing application software can’t be touched. If that’s the case, and the existing application is probing SERIALCOMM to discover ports, this won’t work.

thanq for ur advice
now i got that i have to go for kmdf…i spent up to 10 days on umdf…i found out serial example code in wdk kit(6000/srs/kmdf)…can i use this for my purpose…and could u tell me what changes i have to make in that driver to make it a filter driver if u had any idea…just asking for to save time cosuming…should usb func driver as kmdf driver if we develop filter driver in kernal mode…
thanks i n advance…

To convert the serial sample to use USB, remove the fields for the hardware interrupt and register start from the device context and recompile. Every place you get a compilation error, you need to see how you would do it in usb

d

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@lntemsys.com
Sent: Thursday, June 26, 2008 10:31 PM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] USB 2 serial UPPER filter driver

thanq for ur advice
now i got that i have to go for kmdf…i spent up to 10 days on umdf…i found out serial example code in wdk kit(6000/srs/kmdf)…can i use this for my purpose…and could u tell me what changes i have to make in that driver to make it a filter driver if u had any idea…just asking for to save time cosuming…should usb func driver as kmdf driver if we develop filter driver in kernal mode…
thanks i n advance…


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

hi…
u wrote:"to convert the serial sample to use usb " means
to convert the serial sample to use usb functional driver…only…right?

sukumar gudugunta wrote:

u wrote:"to convert the serial sample to use usb " means to convert the
serial sample to use usb functional driver…only…right?

Yes, “only”. You need to give up on your upper filter idea as it doesn’t make any sense for what you’re trying to do.

hi…
u said i need to give up the serial upper filter…u mean to say that serial sample has to convert as a usb functional driver…how can it possible? our application understands rs232 protocols…
device will understand usb protocol…

sukumar gudugunta wrote:

u mean to say that serial sample has to convert as a usb functional
driver…how can it possible?

Doron *just said* in this thread to convert the serial sample to function as a USB function driver. Now you’re questioning that it’s possible. This amazes me.

Quite simply, the upper edge of the driver will expose a serial-style (“RS232 protocol”) interface, and the lower edge will talk URBs to the USB controller. What’s so hard to understand about this?

On Sat, Jun 28, 2008 at 12:45:46AM -0400, xxxxx@lntemsys.com wrote:

u said i need to give up the serial upper filter...u mean to say
that serial sample has to convert as a usb functional driver...how can
it possible? our application understands rs232 protocols..
device will understand usb protocol......

Right. What do you think a function driver does? A function driver
converts between some interface above, and some interface below. In
your case, your function driver will accept RS-232 ioctls from above,
and will make USB requests below.

A filter driver, on the other hand, attaches itself above or below
some existing driver, and either monitors or alters the requests it
sees. Which existing function driver do you think you will filter?

Tim Roberts, xxxxx@probo.com
Providenza & Boeklheide, Inc.

Hi…
thanq for ur suggestions…i am new to the driver world so i had been to that confusion…now i am follwing the way suggested by u…as u said funstion driver will accept rs232 ioctls from above…
shall we need to take care of all those ioctls like…?
case IOCTL_SERIAL_SET_CHARS: return “IOCTL_SERIAL_SET_CHARS”;
case IOCTL_SERIAL_GET_CHARS: return “IOCTL_SERIAL_GET_CHARS”;
case IOCTL_SERIAL_SET_DTR: return “IOCTL_SERIAL_SET_DTR”;
case IOCTL_SERIAL_CLR_DTR: return “IOCTL_SERIAL_SET_DTR”;
case IOCTL_SERIAL_RESET_DEVICE: return “IOCTL_SERIAL_RESET_DEVICE”;
case IOCTL_SERIAL_SET_RTS: return “IOCTL_SERIAL_SET_RTS”;
case IOCTL_SERIAL_CLR_RTS: return “IOCTL_SERIAL_CLR_RTS”;
case IOCTL_SERIAL_SET_XOFF: return “IOCTL_SERIAL_SET_XOFF”;
case IOCTL_SERIAL_SET_XON: return “IOCTL_SERIAL_SET_XON”;

i mean which r belongs to the h/w …here we r replacing the Evtdeviceprepareharardware function as usb device implement so i thoght these ioctls will not come into picture n we have to take care of ioctls are
case IOCTL_SERIAL_SET_BAUD_RATE : return “IOCTL_SERIAL_SET_BAUD_RATE”;
case IOCTL_SERIAL_GET_BAUD_RATE: return “IOCTL_SERIAL_GET_BAUD_RATE”;
case IOCTL_SERIAL_SET_LINE_CONTROL: return “IOCTL_SERIAL_SET_LINE_CONTROL”;
case IOCTL_SERIAL_GET_LINE_CONTROL: return “IOCTL_SERIAL_GET_LINE_CONTROL”;
becz from appliction we r choosing these fields …am i thinking in correct way if not suggest me…
thanks in advance…

sukumar gudugunta wrote:

case IOCTL_SERIAL_SET_CHARS:
return “IOCTL_SERIAL_SET_CHARS”;
case IOCTL_SERIAL_GET_CHARS:
return “IOCTL_SERIAL_GET_CHARS”;

I don’t think returning a string is going to be particularly helpful to the clients of your driver.

shall we need to take care of all those ioctls like…?

Yes, all of them. It doesn’t matter what the lower edge of your driver is, you have to implement the spec properly or your driver will not work.

in serial sample driver it is implemented that ioctls are mapped to the port…for example if ioctls is
IOCTL_SERIAL_SET_BAUD_RATE.(which used to set the baud rate for the device)…then call will goes to

WRITE_DIVISOR_LATCH(
Extension,
Extension->Controller,
Appropriate
);where conttroller points to the u.port.start(h/w register addres)
in our case lower edze usb implememtation will talk to the port…n i thought we have to map this ioctls to usb pipe…if my assumption is right we hve to cofigure usb pipe as a port… is it possible?
if could u tell me how to implement this…

sukumar gudugunta wrote:

if my assumption is right we hve to cofigure usb pipe as a port… is
it possible?

No, you can’t “configure” something to be totally different than what it inherently is. A USB pipe is a USB pipe, not anything else, and the whole POINT of your driver is to translate the serial spec coming from above into meaningful I/O to your device … which has already been explained to you.

> meaningful I/O to your device …
if ioctl as sebaudrate… in sample it is implemented as i explanied before…can u tell me what to do
for this ioctl…i thought target usb pipe baudrate has to match with serial baud rate…so i assumed that…

sukumuar gudugunta wrote:

can u tell me what to do for this ioctl…

No, because I have no idea about your device.

i thought target usb pipe baudrate has to match with
serial baud rate…

USB doesn’t have “baud rates” at all.

>your function driver will accept RS-232 ioctls from above,
and will make USB requests below
to make this possible i am following wdm samples…becz in kmdf URB(usb request blocks ) r hidden by providing framework objects.
and i found one statement that
“USB client drivers set up USB request blocks (URBs) to send requests to the host controller driver. The URB structure defines a format for all possible commands that can be sent to a USB device.”
can u tell meis it the right way to solve the issue?
can we do all these ioctls setting n getting the baudrates by sending URbs to the host controller driver in lower edze…