How can I debug a USB HID device that does not come with a driver? - usb

I have a single button USB controller, but it did not come with any drivers (simply a Windows program that communicates with it directly for its intended purpose).
USB Fidget
Vendor ID: 0x1d34
Product ID: 0x0001
Product name: DL100A Dream Cheeky Generic Controller
So, I would like to be able to read whether or not the button is being pressed. My main development environment is Mac, but I'd like the solution to run on Windows too. So ideally a cross platform solution would be best.
I can find pieces of code for other devices by the same manufacturer but there are differences in Product ID so the code does not work and I lack understanding to change anything other than the vendor/product.
As far as I understand it I need to poll the USB device with a feature request packet?
Is there some software I can use to "watch" the USB device so I can see what is actually happening when I press the button? If not, how would I go about writing some myself?

basically on MacOs very huge amount of usb devices work through IOUserClient. This standart class provide to user mode programs ability to control device without kernel mode driver (by using usermode part of IOKit framework). To sniff for usb packets you can use USB Prober, start from this article http://developer.apple.com/library/mac/#qa/qa1370/_index.html
On windows standart way - standart USB driver + standart HID driver, no need in specific vendor driver if they not develop some additional functionality over standart. You can use any of commercial or freeware tools to sniff usb packets - like this one http://www.hhdsoftware.com/usb-monitor

I don't know of any cross platform way to handle it. This is the presentation I point people to for how to create a driver app for a random piece of HID hardware:
https://developer.apple.com/videos/wwdc/2011/?id=207

For testing / accessing HID devices, i.e.
Get Feature Report (matt's original question)
Sending Feature Reports
Sending Output Reports
Receiving Input reports
I'd suggest the "HIDAPI Test Tool" / "testgui" included in the great cross-platform HID library from signal11/hidapi.
On Windows you require an additional 3rd party package to compile the testgui application, but it was pretty easy and the GUI tool was more straightforward that other code examples and tools I saw. (I could cross-check if I am maybe allowed to publish a VS2008 compiled version of this.)
Another free option for sending output reports and receiving input reports, is our own "Docklight" tool (in evaluation mode, unlimited time, just no storing), see Docklight Scripting HID USB.

Related

Talk to an USB HID device from within GNU Octave

I need to control a measurement instrument from within GNU Octave. The instrument has an USB HID interface. I just need to read or change the settings of the instrument. It's not about getting measurement data from the instrument.
What options are there to do this from within GNU Octave, and how do they work?
The simplest approach would be to use an already made Octave package (like the instrument-control package). Then you could check the documentation and read /write to and from a USB device.
The package linked above (and here again) has a USB TMC set of functions if the USB device works with this library. See the function list to find out how to use the package. As far as I am aware this package only works on Linux for USBTMC (according to the wiki).
Otherwise if you are not running Linux, or the device is not supported, I cannot specifically see any other already-written set of Octave functions for communication.
However, if you have the time it could be worth writing just a singular MEX (C/C++) function to open the communication channel and read settings from the device.
You could then make this work on Windows as well. Most of this functionality is already implemented in libraries such as signal11 (just to name one...), which that library itself is already cross-platform. Using that library inparticular makes it look like a very short MEX file to write.
I hope this helps and check out the links for further information about the topics discussed :)

ISA port communication with Visual Basic

Is there any chance how I could write something to ISA card in Visual Basic .Net for Windows XP and higher? (I know Win XP and higher have restriction so U cant directly write data to port)
I have also done some research and if I understand the situation I have only 2 options:
Write driver (very problematic option :)) or
Try to use existing driver in kernel32 like driver to serial/paralel port.
If there arent any other options, how I have to modify "using of serial/paralel port" to use it for ISA port?
Modern versions of Windows will not allow direct port I/O from a user application. Your program is running in Ring 3, not Ring 0. You need some kind of driver to do the port I/O on your application's behalf.
The first thing to do would be to contact the card manufacturer and see if they made a Windows driver for your board.
If a Windows driver is not available, and you are only looking to do basic reigster reads and writes (no interrupts or DMA), there are some freely-downloadable libraries that you can download to do port I/O. Basically, the library includes a dummy "driver" that sits in Ring 0 and does the I/O for you. I have the most experience with WinIO.
WinIO has a C/C++ API, nothing .Net/CLR. You will need to use P/Invoke to call the WinIO functions from managed code.
If you search around, you may find a toolkit similar to WinIO that provides APIs for managed code. (Edit: Here is one I have bookmarked called DirectIO.)
The biggest problem with WinIO is that you are limited to basic register reads/writes. If you need interrupts or DMA, you are out of luck. At that point, you will need to write a "real" driver.
Writing a driver can be a pretty major task for the uninitiated (there is a lot you will screw up). You will need to start by getting a copy of the Windows Driver Kit, and studying Microsoft's Kernel Mode Driver Framework. You could also look into purchasing a copy of Jungo WinDriver. WinDriver is a third party tool that simplifies driver development considerably, but it is quite expensive for a one-off project.

Camera compatibility

I have an usb-camera with its drivers and dll with some functions to use this camera in my solutions. I want to use it in any wide-spread applications, to be able just to choose and use it in Skype, for instance. So. I want to develop something that will allow me to use this device as usual web-camera.
I've heard something about such technologies as "Upper-Level Filter Drivers" and "user-mode DirectShow source filter". Looks like it something that can help.
So the question is: what technologies exist for such tasks? What technology should I choose to solve my problem if I have no skills of driver development?
Skype still uses DirectShow for video capture and user mode filter will do the job. Still Skype makes certain unreasonable assumptions that limit compatible source filters, such as if the developers stopped development/testing as soon as they had their favorite USB cam working and ignoring all other devices users might possibly want to attach.
One of the options you were suggested (in Russian - 1, 2) was to develop a kernel mode driver so that your device is visible to apps through standard WDM Video Capture Filter. This is possible and would work, though in my opinion it is a huge overkill.
Fitting custom source filter is not easy because Skype does not like a debugger attached, however driver development is really a completely different story.
The Skype Forum link you refer to is clearly misleading. The poster complains that Skype update broke compatibility with video sources. And response from admin is about audio devices, and is irrelevant.

Spoofing a game controller

I'm trying to write something that will allow a user to use a keyboard/mouse combination on a games console. The approach I've thought of is to do the following:
Figure out how input maps to output in the console's controller. This is good old trial and error, basically connecting the controller via USB to a computer and figuring out how the controller responds to input using detailed USB logging.
Then, write a userland program that takes keyboard/mouse input and converts it to the controller's output.
So far so good. Now comes the complicated bit. I need to figure out a way to connect my computer to the console, while making the console think that what is actually being connected is a standard controller. For this, I will need a way to create a fake USB device, which communicates over a USB port to the console. This is the part that I have no idea whatsoever how to do.
I guess I'm looking for a USB spoofing library of some sort, but I'm not sure where to start looking for something like this. Python bindings for the library would be great, but I'm not fussy. Similarly, something that works on Mac or Linux would be perfect, but I could live with a Windows-only library in a pinch.
USB doesn't work this way. USB involves a directed hierarchy of devices, and trying to connect two host devices (your computer and a console) will only result in bad things happen (like destroying the USB controllers in both devices).
Probably the best thing to do would be to use some sort of embedded processor like an Arduino to sit between your keyboard/mouse and the console to do the conversion.

How to write a generic USB Host Driver for Printers from various vendors?

I want to develop a USB host on an embedded device that will talk to printers from various vendors. Drivers for the vendor specific printers would be available on PC which is ultimately communicating with printer but my device is facilitating this communication and needs to perform the basic handshaking/setup of the printer (i.e, it needs to know when the printer is connected, what are the socket IDs that needs to be opened for CTRL and DATA transmissions etc). All of these printers are supposed to comply with IEEE 1284.4 standards but I see that many of them vary quiet a bit.
One approach I have is to take the USB traces of handshaking from each of these printers and write various sections of code respectively (I know, that sounds ridiculous!). Is there a generic way to do this? Is there any available forum where these standard informations are mentioned? For eg: EPSON uses 'EPSON-CTRL' and 'EPSON-DATA' for its control and data services which needs to be provided to get the socket ID for these services. I am pretty sure HPs, Canon's etc would have their own service names as well. As per the standards, this was supposed to be captured in IANA but I dont see anything there. Any help on this would be greatly appreciated.
Thanks and regards,
Ullas
No, you can't do this because EPSON and HP will implement their printers differently even if they do the exact same thing. Your "generic" driver will have to explicitly account for each type of printer.
That being said, you could theoretically implement each driver type in your generic driver suite and have it determine which driver to use when the printer becomes available. But, this seems like a bit of overkill since you can just get the drivers free online at the manufacturer's website.