Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to transmit data via USB HID(/dev/hidg0)?

Tags:

usb

I'm using Atmel sama5d3x serials. I implement device to USB HID device (as keyboard). Already try the configuration of kernel for both USB HID to g_hid.o(built-in_ or g_hid.ko module), then Windows can identify as keyboard, event device has interface (/dev/hidg0) there.

How can I transmit data via this interface?

Kernel version : 3.14

like image 445
Dapump Avatar asked Dec 14 '25 19:12

Dapump


1 Answers

I guess your question is "how can i transmit data via the interface from the Linux".

From Linux userspace, you can open /dev/hidg0 with mode wb and then simply write to this file descriptor.

For instance in Python:

with open('/dev/hidg0', 'wb') as fd:
    fd.write(data_to_sent_over_hid)
like image 117
OlivierM Avatar answered Dec 19 '25 06:12

OlivierM



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!