Control a subset of the available controls of a USB HID device - linux

I have a USB HID device which acts as a normal USB HID keyboard. In addition it implements some additional commands (USB HID display).
Is there any way I can write a driver/application to control the display part while leaving the keyboard part up to the kernel/built-in HID drivers?
I already tried to claim the endpoint using libusb. That did not work out as the internal generic USB HID driver already did that.

You can use a HID library like libhid to connect to the USB HID driver instead of trying to take over it.

Related

USB HID Enumeration with BLED112

We are trying to make an USB HID enumeration to simulate a keyboard device on a BLED 112 (with MCU C8051): http://www.silabs.com/products/wireless/bluetooth/bluetooth-low-energy-modules/ble121lr-bluetooth-smart-long-range-module1
We read in the BLUETOOTH SMART MODULE (last version : 12/20/2016) that : "There is no support in the current BLE stack for other types of USB enumeration such as USB HID or other protocols".
But we found examples to make HID keyboard, but only in one way : computer to usb dongle.
So we would like to know if it is possible to make an HID usb enumeration where the dongle send keyboard event to the computer.
If someone have clues, example, or other, it will be great
thanks for your help.
just for information, this is the response given by the silicon labs technical team :
"Unfortunately that is not possible, the BLED112 enumerates as a USB CDC device only. It communicates with the PC using BGAPI messages which is our proprietary protocol to interface with our modules."

Enumerate commands available for a usb chip in fedora 24

I am learning to program a USB device (iBall 3.5g USB Dongle) using libusb.h header library.
Until now I am able to identify my device using the Vendor ID and also open the device for operation.
As a next step I would like to know the available commands (or the controls) for example : command to scan the surroundings for available GSM networks.
Obviously I will have to talk to the devices' firmware to extract the necessary information.
I tried to search for the technical datasheet for the 3g dongle, but couldn't find any.
The dongle is powered by a Qualcomm chip
Do you know any of the methods in which I can get the control commands for a usb device ?
Thanks in advance.
There is no simple procedure for figuring out what commands a USB device has. You need to use a combination of looking at the descriptors reported by the device, seeing if the device supports any particular USB device class, reading the USB specification, and maybe doing some reverse engineering using a protocol analyzer.
A good first step would be for you to use lsusb -v to print human-readable descriptions of the device's USB descriptors.

Detect OS by HID device

I have a HID keyboard stack on my microcontroller, I have a question, whether HID device after plug-in obtains some information about operating system it is connected to?
Not directly, but you can figure it out in the early handshake process between the USB devices via the Configuration Descriptors.
Check out these links:
https://stackoverflow.com/a/30362736/759341
https://www.google.com/patents/US20120054372
http://www.usb.org/developers/hidpage/HID1_11.pdf

Accessing Linux /dev/USB as standard files to communicate with USB device

I'm researching ways to communicate with a USB device in Linux and would prefer to not write a Linux Kernel driver. I understand that libusb exists and is a user-land library that would work, but our embedded device doesn't support usbfs ( and would be really a pain to change kernels to add the support ).
So my question is basically this: Is it possible / advisable to communicate with a USB device by directly reading and writing to the /dev/USB or the udev file corresponding to the USB device thus bypassing the need for a custom Linux Driver and usbfs?
I'm hoping it's possible to communicate using the USB devices protocol just by reading / writing protocol packets directly through file-type read/write commands once the /dev/USB or udev device file is open.
Thoughts and suggestions please.
FOLLOW UP:
Since the USB device I needed to talk to is a USB HID class device, I was able to use libudev and the standard Linux USB HID RAW driver by reading / writing directly to /dev/hidraw0 ( or the appropriate /dev/hidraw device ). It wasn't necessary to write a custom driver for a simple USB HID device.
Jim, I don't think you can escape the need to write a driver and just manage to read the USB file in /dev. Because who defines as to what should happen when you do a read() on the USB device file? And who defines what action should be initiated when you invoke sysioctl()? Your driver! In other words, the device files are themselves incapable of anything until they are supported by the underlying drivers. In fact, you can treat the device files to be an abstraction of the underlying driver! So, no driver, no use of device file :(
I suggest you go through the following articles about how to write a driver and also understand the USB internals-
http://www.linux-usb.org/USB-guide/c15.html
http://www.linuxjournal.com/article/4786 ( Slightly outdated )

Read a Device in GNU/Linux or FreeBSD

I am wondering, do you need a specific device driver to read a usb device in Linux, or should it just be able to be read. If I connect my cell phone or iPod touch to my linux box, it is not found is /proc/partitions and thus is not a mountable device by fdisks standards, though gnomes nautilus does in fact mount the iPod but not the windows mobile touch pro cell phone.
So I am interested, If I just wanted to read a device(iPod touch) in linux, how can I do so. How can I get a hold of a descriptor of a set usb device so I can read it.
Thanks all.
You can access raw USB endpoints under /dev/usbdev. There is user-space libusb that makes it easier.
Unfortunately there is no simple concept of "just read it" for USB devices (I am assuming that you are not referring to reading and writing the data on the USB bus that make up the USB protocol). In short, you always need a device driver for accessing a USB device and it is up to the driver to implement "the abstraction" of the device used by the system (disk, serial device, etc).

Resources