Hello,
I am currently working on receiving and outputting raw HID data from a device (e.g., mouse or USB receiver) connected to the USB host of a Teensy 4.1. While I am confident that the wiring is correct - since I can successfully receive all data using the MouseController class - I encounter an issue when attempting to receive raw HID data. Specifically, I only see the message “Waiting for data...” once, and no further data is received/printed.
Could you advise on what I might be missing or how I can resolve this?
Thank you for your assistance.
Here is my approach:
I am currently working on receiving and outputting raw HID data from a device (e.g., mouse or USB receiver) connected to the USB host of a Teensy 4.1. While I am confident that the wiring is correct - since I can successfully receive all data using the MouseController class - I encounter an issue when attempting to receive raw HID data. Specifically, I only see the message “Waiting for data...” once, and no further data is received/printed.
Could you advise on what I might be missing or how I can resolve this?
Thank you for your assistance.
Here is my approach:
C:
#include <USBHost_t36.h>
USBHost usb_host;
USBHIDParser usb_hid_parser(usb_host);
RawHIDController raw_hid_controller(usb_host);
// Callback function to handle received HID data
bool handleHIDData(uint32_t usage, const uint8_t *data, uint32_t len) {
Serial.print("Received HID data (Usage: ");
Serial.print(usage);
Serial.println("):");
for (uint32_t i = 0; i < len; i++) {
Serial.print(data[i], HEX); // Print each byte in hexadecimal format
Serial.print(" ");
}
Serial.println();
return true;
}
void setup() {
Serial.begin(115200);
usb_host.begin();
Serial.println("Waiting for data...");
// Attach the receive callback function to print HID data when received
raw_hid_controller.attachReceive(handleHIDData);
}
void loop() {
usb_host.Task();
}