Interfacing to USB port from User Mode?

Sorry guys if I’m being naive in this, but still…
Suppose I have a device (black box) that is plugged into USB port. It’s not a mass storage, or audio or COM or any other standard (in Windows realm) device, just a device that has a USB connection. Now, do I still need to write a driver for this device to enable my UM app to read/write data from/to this device? Or there is a standard USB protocol (read/write/IOCTL) that allows my app to talk to physical device without necessity to write a driver? In essence, can I view USB as a COM port just “faster” and having different protocol? If so, are there any samples/docs that would show me how to accomplish this?

Any suggestions/comments are greatly appreciated!

Vladimir

xxxxx@gmail.com wrote:

Sorry guys if I’m being naive in this, but still…
Suppose I have a device (black box) that is plugged into USB port. It’s not a mass storage, or audio or COM or any other standard (in Windows realm) device, just a device that has a USB connection. Now, do I still need to write a driver for this device to enable my UM app to read/write data from/to this device? Or there is a standard USB protocol (read/write/IOCTL) that allows my app to talk to physical device without necessity to write a driver? In essence, can I view USB as a COM port just “faster” and having different protocol? If so, are there any samples/docs that would show me how to accomplish this?

No, it isn’t that simple. A device can have multiple interfaces, each
of which can have multiple pipes, each of which can use different
protocols. You’ll need a driver of some kind. In some cases, it’s
easier to cobble up a single kernel driver, but unless you need Windows
2000 support, you now have the option of writing a user-mode driver with
UMDF, or even using the generic WinUSB driver. Both options keep
everything in user-mode.

You will need the specs for the device. You cannot guess at the protocol.


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

Thanks Tim!

Device as well as the protocol belongs to me. I developed and implemented it (I mean not me personally but “us”). Sorry, that “black box” statement was misleading.
What I’m trying to avoid is having to write a driver to interface to this device. What I’m trying to accomplish is to use “standard” USB driver(s) to talk to my device directly from the UM. I’ve noticed that there is a IOCTL_USB_USER_REQUEST that “sort of” claims that it can be sent from UM but the doc on this is in DDK and pays no attention to how to use it from UM. So, I don’t know if this IOCTL is usable for my purpose at all. Plus, it’s also unclear for me how do I open my USB device (how do I get name of the USB port to which device is attached to pass to CreateFile).
Well, I know that this sort of questions is very irritating because you have to start answering from the “Big Bang” moment and I apologize for that. I’m just trying to get a feeling on whether or not I really need to write a driver to enable USB communication between my device and my application. And if I can avoid writing driver I need some starting point (ideally some sample code) to write a prototype for this communication.

Can you help me with these answers?

TIA,

Vladimir

It’d help if you describe your device from USB perspective. The easiest way could be to dump descriptors to readable from; you can use UsbView for this purpose.

There is a chance some of OS USB drivers would match your device and then everything you need is to write an INF file to install this driver for your device.

Best regards,

Michal Vodicka
UPEK, Inc.
[xxxxx@upek.com, http://www.upek.com]


From: xxxxx@lists.osr.com[SMTP:xxxxx@lists.osr.com] on behalf of xxxxx@gmail.com[SMTP:xxxxx@gmail.com]
Reply To: Windows System Software Devs Interest List
Sent: Wednesday, April 18, 2007 12:28 AM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] Interfacing to USB port from User Mode?

Thanks Tim!

Device as well as the protocol belongs to me. I developed and implemented it (I mean not me personally but “us”). Sorry, that “black box” statement was misleading.
What I’m trying to avoid is having to write a driver to interface to this device. What I’m trying to accomplish is to use “standard” USB driver(s) to talk to my device directly from the UM. I’ve noticed that there is a IOCTL_USB_USER_REQUEST that “sort of” claims that it can be sent from UM but the doc on this is in DDK and pays no attention to how to use it from UM. So, I don’t know if this IOCTL is usable for my purpose at all. Plus, it’s also unclear for me how do I open my USB device (how do I get name of the USB port to which device is attached to pass to CreateFile).
Well, I know that this sort of questions is very irritating because you have to start answering from the “Big Bang” moment and I apologize for that. I’m just trying to get a feeling on whether or not I really need to write a driver to enable USB communication between my device and my application. And if I can avoid writing driver I need some starting point (ideally some sample code) to write a prototype for this communication.

Can you help me with these answers?

TIA,

Vladimir


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

Like Tim said, you want to use UMDF or WinUSB. If you want to share
device state/data across multiple applications, you need to use UMDF.
If your device is used strictly by your application, then you can use
winusb without UMDF. You should download the WDK
(http://blogs.msdn.com/doronh/archive/2007/04/11/the-wdk-iso-download-li
nk-has-been-moved-off-of-whdc.aspx), there are both winusb and UMDF
samples and complete documentation for the winusb interface.

d

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@gmail.com
Sent: Tuesday, April 17, 2007 3:28 PM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] Interfacing to USB port from User Mode?

Thanks Tim!

Device as well as the protocol belongs to me. I developed and
implemented it (I mean not me personally but “us”). Sorry, that “black
box” statement was misleading.
What I’m trying to avoid is having to write a driver to interface to
this device. What I’m trying to accomplish is to use “standard” USB
driver(s) to talk to my device directly from the UM. I’ve noticed that
there is a IOCTL_USB_USER_REQUEST that “sort of” claims that it can be
sent from UM but the doc on this is in DDK and pays no attention to how
to use it from UM. So, I don’t know if this IOCTL is usable for my
purpose at all. Plus, it’s also unclear for me how do I open my USB
device (how do I get name of the USB port to which device is attached to
pass to CreateFile).
Well, I know that this sort of questions is very irritating because you
have to start answering from the “Big Bang” moment and I apologize for
that. I’m just trying to get a feeling on whether or not I really need
to write a driver to enable USB communication between my device and my
application. And if I can avoid writing driver I need some starting
point (ideally some sample code) to write a prototype for this
communication.

Can you help me with these answers?

TIA,

Vladimir


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

I am having a very similar problem. We are producer of a simple USB
device, that is using a Freescale microprocessor with USB protocol. We
have been using a driver from another company. With Vista, there are
problems with our old driver, so we need something new.

It would be nice if we could use the new features in Vista, for then I
suppose that this will work in next Windows version also.

I have been checking the documentation in WDK 6000 a little. I knows
the USB protocol from the device end and from the application, but not
so much in the OS end.

It would be nice to have a solution that does not tell the user that
this piece of software is not certified or verified or something like
that, so that the program is installed without anything that can make
our customers suspicious about our program.

The device is very simple and is just using one endpoint for data and
one for control. The most complicated thing I am using is SETFEATURE and
CLEARFEATURE.

What is the real difference between a UMDF driver and using WinUSB?
If I write a driver with UMDF, what about certified code and digital
signature?
I assume that if you are using WinUSB, you will make an inf file for the
device that loads winusb.sys and then you make calls to WinUSB from the
application.

Kurt Nyström

You are still installing a driver, even if it is inbox in Vista (you can also use winusb downlevel, there is a redistributable you can use to install it on XP as well). Since you are installing a driver, you still need to get your INF signed, otherwise the signing warning will still show up.

The main difference between winusb and UMDF is the abstraction at which you communicate with the device. With UMDF, your application will use read/write/IOCTLs to talk to your UMDF driver. The driver can then arbitrate state and data. For instance, the UMDF driver can translate the raw data from the device into a different format and send that different data format to the application. More than one application can communicate with the device if your UMDF driver allows for it.

If you use WinUSB without UMDF, your application uses winusb APIs to communicate with the driver. State and data are tied to the application and it is up to the application to keep it private or share it out. The application deals with the raw data from the device without any interpretation from lower layers.

Hope that helps
d

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Kurt Nystr?m
Sent: Tuesday, April 17, 2007 4:51 PM
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] Interfacing to USB port from User Mode?

I am having a very similar problem. We are producer of a simple USB
device, that is using a Freescale microprocessor with USB protocol. We
have been using a driver from another company. With Vista, there are
problems with our old driver, so we need something new.

It would be nice if we could use the new features in Vista, for then I
suppose that this will work in next Windows version also.

I have been checking the documentation in WDK 6000 a little. I knows
the USB protocol from the device end and from the application, but not
so much in the OS end.

It would be nice to have a solution that does not tell the user that
this piece of software is not certified or verified or something like
that, so that the program is installed without anything that can make
our customers suspicious about our program.

The device is very simple and is just using one endpoint for data and
one for control. The most complicated thing I am using is SETFEATURE and
CLEARFEATURE.

What is the real difference between a UMDF driver and using WinUSB?
If I write a driver with UMDF, what about certified code and digital
signature?
I assume that if you are using WinUSB, you will make an inf file for the
device that loads winusb.sys and then you make calls to WinUSB from the
application.

Kurt Nystr?m


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