Posts

Showing posts with the label usb

Learning USB HID in Linux Part 7 - Understanding Keyboard Report Descriptors and Reports

Image
The below is the Report Descriptor of USB Keyboard connected to my system: usbhid-dump -d 413c:2107 | tail -n +2 | xxd -r -p | hidrd-convert -o spec Usage Page (Desktop),               ; Generic desktop controls (01h) Usage (Keyboard),                   ; Keyboard (06h, application collection) Collection (Application),     Usage Page (Keyboard),          ; Keyboard/keypad (07h)     Usage Minimum (KB Leftcontrol), ; Keyboard left control (E0h, dynamic value)     Usage Maximum (KB Right GUI),   ; Keyboard right GUI (E7h, dynamic value)     Logical Minimum (0),     Logical Maximum (1),     Report Size (1),     Report Count (8),     Input (Variable),     Report Count (1),     Report Size (8),     Input (Constant),     Report Count (...

Learning USB HID in Linux Part 5 - Collections, Usage Maximum, Usage Minimum, Logical Maximum, Logical Minimum

Image
Collections Report descriptors are made up of items; an item is distinct grouping of data. Collection items are used to group together input, output and feature items. In the HID Specification, there are 3 different types of predefined collections: Physical Application Logical Physical: Data collected at one physical point. Devices that collect data from multiple sensors at one time may group the data in physical collection Eg. Mouse position Data. Application: Groups together items that serves different or common purposes in a single device.  Eg. Keyboard that groups together the LEDs and key presses. Usually, every Report Descriptor must define at least one Application Collection but you may have two or more. Logical: Indicates that some bits of data belong together, whatever that means. Example from HID Spec: Contents of data buffer and buffer length Usage Minimum and Usage Maximum assigns a series of Usage IDs to the data in the array or bitmap. Usag...

Learning USB HID in Linux Part 6 - Understanding Mouse Report Descriptor and reports

Image
jamal@ubuntu:~/hidrd$ sudo usbhid-dump -d 0458:003a | tail -n +2 | xxd -r -p | hidrd-convert -o spec Usage Page (Desktop),               ; Generic desktop controls (01h) Usage (Mouse),                      ; Mouse (02h, application collection) Collection (Application),     Usage Page (Button),            ; Button (09h)     Usage Minimum (01h),     Usage Maximum (03h),     Logical Minimum (0),     Logical Maximum (1),     Report Count (3),     Report Size (1),     Input (Variable),     Report Count (1),     Report Size (5),     Input (Constant, Variable),     Usage Page (Desktop),           ; Generic desktop controls (01h)     Usage (Pointer),             ...

Learning USB Hid in Linux Part 4 - Usage Page, Usages, Report Size and Report Count

Report Descriptor defines the format and use of the data in the HID's report. Report descriptor needs to be flexible enough to handle devices with different purposes. Data should use a concise format to keep from wasting storage space in the device or bus time when the data transmit. HID Report descriptors achieve both goals by using a format that's more complex and less readable than a more verbose format might be. A usage provides information to an application developer about the intended meaning and use of a particular item described in the Report Descriptor. HID Usages are organized into usage pages of related control.  A usage page value is an unsigned 16-bit value. Eg: Generic Desktop Control, Game Controls, LEDs, Buttons etc In the context of usage page, usage id indicates a usage in the usage page. A value of zero is reserved. A Usage ID is an unsigned 16-bit value. The combination of Usage page and Usage ID uniquely identifies a specific Usage in the Usage ...

Learning USB HID in Linux Part 3 - Printing reports using usbhid-dump

Image
usbhid-dump is a USB HID Dumping utility based on libusb-1.0. It dumps Report Descriptors Reports Print Report descriptors using usbhid-dump:   You can see from the above output, the report descriptor is printed in hexadecimal form. To dump report descriptor in human readable form, you can use hidrd-convert utility along with usbhid-dump. hidrd-convert utility doesn't come by default on Ubuntu, You need to manually install it. Steps to install hidrd-convert: 1.  sudo apt-get install autoconf 2.  sudo apt-get install libtool 3. git clone https://github.com/DIGImend/hidrd 4. cd hidrd 5. ./bootstrap 6. ./configure 7. make 8. sudo make install 9. sudo ldconfig Print report descriptors in human readable format using hidrd-convert:   Printing reports using usbhid-dump:     Syntax: sudo usbhid-dump -d <vid>:<pid> -e all Move the mouse or click buttons you will see lot of reports being recei...

Learning USB HID in Linux Part 2 - Print Report Descriptors

Image
I have connected a mouse over USB to my Ubuntu Linux machine lsusb is command which comes with usbutils package To find out the Report Descriptors, run lsusb -vd <vid>:<pid> In my case:  $lsusb -vd 0458:003a If you get error like "Report Descriptors unavailable" as shown below Run the command as root: $sudo lsusb -vd 0458:003a

Learning USB HID in Linux Part 1 - Basics

What is HID? HID stands for Human Interface Device. From Wikipedia: "HID is a device used by humans which takes input from humans and gives output to humans" Examples: Joysticks, Mouse, Keyboard, Barcode Readers, volume controls on speakers/headsets Why was HID Created? Replacement of PS/2 Creating interface over USB and to have a generic driver for HID devices like keyboard, mice and game controllers.  Components of HID? Device: Interacts directly with human such as mouse, keyboard Host: Communicates with device and receives input data from the device on actions performed by the human. Output data flows from host to device and then to human HID was originally defined to use over USB, but now used with other transport layers like 1. Bluetooth HID 2. HID over I2C 3. HOGP (HID over GATT Protocol) We will be discussing mainly in this series on USB HID.  HID Terminology Reports: Communication in HID Happens using "Report...

simple usb driver in linux

#include<linux/module.h> #include<linux/init.h> #include<linux/usb.h> MODULE_LICENSE("GPL"); /* When the device is inserted into the USB bus and the vendor id and product id matches with the driver registered in the core,the probe function is called.The usb_device structure,interface number and interface id are passed to the function */ static int toshiba_probe(struct usb_interface *interface,const struct usb_device_id *id) { printk("\n In probe function"); return 0; } /* This function is called whenever the device is removed from the USB device */ static void toshiba_disconnect(struct usb_interface *interface) { printk("\n In disconnect function"); } /* struct usb_device_id  structure provides a list of different types of USB devices that the driver supports */  static const struct usb_device_id usb_table[] = { { USB_DEVICE(0x13fe,0x1d00) }, { }, /*Terminating entry*/ }; /* To enable the linux hotplu...

Pen-drive read only system error ubuntu

 Pen-drive is saying Read-only FileSystem whenever we are coying some thing in ubuntu In order to solve this error just type this command in command line dosfsck -a -v /dev/sdc /dev/sdc is the place where your pendrive is present. You can get it by typing dmesg|tail Now you can cut,copy,paste anything in your pendrive