cancel
Showing results for 
Search instead for 
Did you mean: 

How to send data from Computer to Keyboard in a USB-HID device?

sibufavica sibufavica
Associate II
Posted on April 10, 2018 at 09:18

I am designing a custom keyboard with an LCD display that displays custom messages using STM32F103. I have made the USB HID to work with the code generated from CubeMX. But I am unable to figure out how to send data from computer to the keyboard. As per my understanding, HID protocol is a keyboard to the computer. 

Any hint on this is highly appreciated.

P.S. I am planning to use pyusb (python) to send data from computer to keyboard.

#usb-hid #usb_device #usb-device
1 ACCEPTED SOLUTION

Accepted Solutions
Posted on April 11, 2018 at 10:43

CDC is not necessarily handled as virtual serial port, it's just the default host side driver loaded for it in most OSs. You can always replace that driver with your own, or e.g. WinUSB. Then you can find the device with VID/PID, and use the data endpoints to transfer raw data.

View solution in original post

3 REPLIES 3
Ben K
Senior III
Posted on April 10, 2018 at 13:51

If you intend to use the device as a normal keyboard without writing your custom driver for it, you should leave the HID interface as it is. Create a composite USB device which has another interface (e.g. CDC) for your needs besides the HID keyboard, and they can operate independently, and you can only handle the new interface on the PC.

Posted on April 11, 2018 at 04:30

I know about CDC, I don't want to use it, as every time I might have to manually select the COM port when I connect to different PC. Other than CDC, is there any other protocol which I can use?

Posted on April 11, 2018 at 10:43

CDC is not necessarily handled as virtual serial port, it's just the default host side driver loaded for it in most OSs. You can always replace that driver with your own, or e.g. WinUSB. Then you can find the device with VID/PID, and use the data endpoints to transfer raw data.