How to implement a USB device driver for Windows? - c

How should I approach implementing a USB device driver for Windows? How should I take into account different versions of windows e.g:
- Windows XP
- Windows Vista
- Windows 7
Is there open source solutions which could be used as a starting point? I'm a total newbie to windows driver development.
We have an embedded device with USB device port and we would like to have as low latency communication from the application level to the device as possible without sacrificing the data throughput. The actual data transferred is ADC/DAC data. Basically there is a lot of data which we need to transfer to a Windows machine as fast as possible.

We need more information about the device to point you in the right direction, but here are a few steps to get you started:
register with Microsoft Connect so you can download the Windows Driver Kit
register with osr-online as you'll find great articles, plenty of information, and a newsgroup dediciated just to Windows drivers -- this place is a goldmine
buy Developing Drivers with WDF, which will help you make sense of driver development on Windows and give you a good foundation to read articles from OSR and Microsoft
Hope that you can use UMDF (user-mode drivers) as you can use C++ and just write COM code. If you're doing anything with USB that requires kernel-space....you've got a lot of reading and learning to do for the next year!
To answer your question on versions, the Driver Kit has tools that will help you manage creating different drivers. If you write a good driver, it should run on all three OS with no problems, and the differences will just be in the config area (not the binary)
Basically, it depends on how complex your device is. What type of driver are you trying to write? File system? MP3 player? Camera? Modem?
If you end up having to write a kernel mode driver, let me know and I can point you to some good articles and what not.
I should also add that for around US $5,000, you can buy a license for WinDriver, a tool that takes all of the hard stuff out of driver development. You can use C++ or C# user-mode code to communicate with their driver that is custom generated for your device. This is the way to go if you have a tight deadline.

You can take a look at windows variant of libusb *here*. There are wrappers for many programming languages on official libusb site and on the web.

Start here: Windows Driver Kit Introduction

If you have some form of control over the device side, have it implement an interface for which Windows already provides drivers. E.g. the USB HID class (literally Human Input Device, but neither the Human nor the Input is mandatory) already has Windows drivers, and there is a reasonable Win32 API on top. You're not going to get data rates anywhere near 480 Mbps, though.

Related

How to control video card in my self-developed OS?

I am developing my own OS and for days I’ve been wondering how to control video card, audio card to build a delicate GUI. It seems that the procedure is a bit different from that of controlling mouse or keyboard.
By the way,
1.How does an OS recognize hardware drivers?
2.Are all hardware drivers written for specific platforms (such as Windows,Linux,etc.)?
Still freshman in the university and failed to find relevant information
thanks for help =)
how to control video card
Graphics cards typically support a VGA mode and the VESA 2.0 standard. So this could be a good starting point for your first video driver.
How does an OS recognize hardware drivers?
Linux uses a device tree describing the hardware which has a compatible field for every item that needs a driver. All hardware drivers are kept in linker generated lists. If a driver has the same compatible value it can be used to drive the hardware. The linker list item is generated from a macro in the driver code using a specialized linker script.
Are all hardware drivers written for specific platforms (such as Windows, Linux, etc.)?
If you provide the right wrappers you may be able to reuse existing drivers. E.g. U-Boot reuses Linux drivers for USB devices. And the NDISwrapper can be used to run Windows WLAN drivers on Linux.

USB HID Device Driver Development in FreeBSD

I am currently developing a driver for an HID device on a FreeBSD system. The idea is that the driver writes to the device's registers through the Control Endpoint. From then on the device acts according to the data fed.
Since I have just started out on drivers, I am following a guide book (I would name it here but I don't know if I can? ). This book tackles a USB ULPT (Printer) driver, explaining the basic driver for a USB device. However when I am trying to implement these concepts to the HID device, I am having trouble, more specifically when it comes to identifying and probing the device.
Since I haven't found much material online, I was wondering are there any guides/books or tutorials I can follow which tackle the development of an HID device driver on FreeBSD or at least Linux systems. A pointer (pun intended) to the right direction would be enough to get me going again.

Driver Templates, Minimum Kernel Distro., drivers community, driver for Microcontroller?

I am post-newbie to Embedded Linux driver development, have developed Character, UART & simple USB drivers, and have worked with SBC (Raspberry Pi 2). My main learning resources are: Essential Linux Device Drivers, Embedded Linux System Design & Development, youtube tutorials and LDD3. Because of lack of real life driver experience, I have some questions that I would like to share:
Templates: are there some sort of driver templates for speeding up the coding process e.g. have the regularly used structures & functions for being modified & customized for the specific drivers.
What’s suitable minimum distribution:
What I am doing now is either building a kernel image using Buildroot then inserting the developed USB driver into it OR inserting the developed USB driver into a Ubuntu. And for proper testing I have to unload the default USB driver (usb_storage); otherwise can’t test my module. So, my question is regarding real-life development & how-to get minimum kernel that has no drivers, & how-to include my module into it (to be part of it) while building with Buildroot?
What Embedded Linux Driver Development community do you suggest for detailed Q&A?
i.e. In future if I want to ask about low level detail such as what is this x structure, or I am getting this error while using this y function .... is there a specialized community? because all I found are for Linux in general, for Kernel hacking, or don’t have experiences.
What is the missed link in the chain?
Developing applications for Microcontrollers relies on Datasheet, User Guide, Registers, C, etc. Developing Drivers for Embedded Linux relies on C, Linux API, Subsystems, etc. In most learning resources, I never found a relationship between both. So, are there really separated? OR there is a missed link between them??
e.g. for this I2C sensor http://www.robot-electronics.co.uk/htm/srf10tech.htm we have to manipulate it (send hexa to & receive values from its registers). If we imagine that we want to develop an I2C driver for it, then for sure we would need to do the same from within the driver, which is explained in Essential Linux Device Drivers (page#278). The main point behind it is that I2C core hides many complexes & simplifies driver development process.
However, I expect the case in real life is not for a sensor, instead it might be a Microcontroller or a complicated device. So, how would we manipulate the Registers & Peripherals of this Microcontroller? Also, I didn’t find tutorial for such a case!

Do we need drivers for micro controller which has to communicate with mobile phones?

I am planning to build a micro controller (a switch will be attached to the embedded system which contains this micro controller) and this embedded system will be connected through a wire to mobile phone. My objective is to dial a particular number through the connected mobile phone network when the user presses the switch on the embedded system. ( planning to use AT commands for dialing). After extensive search, I have found that it is possible to do this above task. Some of the questions I have on this :
a) Do we have to install any drivers on the micro controller to communicate with mobile phone (for sending AT commands) i.e., is it sufficient if we simply code the related AT commands in the micro-controller (in C++) ?
b) Many people were using F-bus protocol for this above objective. Is there any other general protocol similar to this which can help for communicating with all mobiles (samsung,nokia,sony..)
I have read extensively in SO also. But, I have not found any question regarding the drivers. I would appreciate any kind of help
Thanks
A driver is nothing more than a software that allows your system to interact other devices, and is usually associated with Operating Systems (the driver might provide an abstraction layer for your communication). Do you plan to use an Operating System at all?
In any case, it is quite obvious that if you want to communicate to another device you need the software to do so. The question is if you write it your self or if you get an "off the shelf" solution.
In many cases, particularly when a device uses a proprietary communication protocol, you have no option but to get a driver to communicate with it, and that most likely will require you to have an Operating System.
If cellular communication is all you need, there are MUCH easier solutions available (particularly if you intend of turning your project into a product). Search for "embedded modems" or M2M solutions. There are lots of available modems to which you connect using RS232, and can send the AT commands directly. Telit and Multitech are two providers I've worked with and are really easy to interface with.

Communicating to USB Device

I bought a usb otoscope from the internet and I want to create an application that uses it. When I plug it into the computer, it reads the device as a USB Camera, and I can use the very barebones software supplied to communicate with it. I'm very new to the idea of communicating with usb all together. I've tried to look at some sites like this: http://www.jespersaur.com/drupal/book/export/html/21, that tell me how to reverse engineer a device. I don't know if I'm going down the right path with this...
I've downloaded USB Snoopy and I can't seem to get it to sniff the packets correctly. I also have Crunchbang linux installed on a different computer but I don't know how to sniff it on that either (especially because the drivers are native to windows). All I want is some sort of API/Interfacing functions for me to call and use. How do I go about doing such a thing? I'm able to locate the device on the device manager in windows, and it tells me hardware ID's and such. I can supply any information if necessary. Thank you.
EDIT - Small description I found of the otoscope: http://microscopesimgv.blogspot.com/2012/08/oasis-ehev2-usbplus-20mp-handheld-usb.html
would this tool help you any?libusbx is a cross-platform user mode library that provides generic access to USB devices
CHEERS!

Resources