There are several devices like keyboards, which run in USB Low Speed (1.5MBps) and are not properly being handled.
For example, I have a Dell keyboard plugged in. I believe this one came with my newer computer I purchased in the last couple of years.
If I run the KeyboardGiga example sketch from the USBHostGiga library it receives, the keystrokes and prints them out in the Serial monitor.
If I instead run a similar test using this library it does not.
/*
USBHost Keyboard test
The circuit:
- Arduino GIGA
This example code is in the public domain.
*/
#include <Arduino_USBHostMbed5.h>
#include <USBHostHID/USBHostKeyboard.h>
REDIRECT_STDOUT_TO(Serial)
USBHostKeyboard kbd;
// If you are using a Portenta Machine Control uncomment the following line
// mbed::DigitalOut otg(PB_14, 0);
void setup()
{
Serial.begin(115200);
while (!Serial) {}
Serial.println("Starting Keyboard test...");
// Enable the USBHost
pinMode(PA_15, OUTPUT);
digitalWrite(PA_15, HIGH);
// if you are using a Max Carrier uncomment the following line
// start_hub();
kbd.attach(&kbd_key_cb);
kbd.attach(&kbd_keycode_cb);
while (!kbd.connect()) {
Serial.println("No keyboard connected");
delay(5000);
}
}
void loop()
{
delay(1000);
}
void kbd_key_cb(uint8_t key) {
Serial.print("Key pressed: ");
Serial.print(key, HEX);
Serial.print("(");
if ((key >= ' ') && (key <= '~')) Serial.write(key);
Serial.println(")");
}
void kbd_keycode_cb(uint8_t keycode, uint8_t mod) {
Serial.print("Keycode: ");
Serial.print(keycode, HEX);
Serial.print(" mod: ");
Serial.println(mod, HEX);
}
I added debug output to the keyboard class... So I know it is being called. Debug shows:
There are several devices like keyboards, which run in USB Low Speed (1.5MBps) and are not properly being handled. For example, I have a Dell keyboard plugged in. I believe this one came with my newer computer I purchased in the last couple of years.
If I run the KeyboardGiga example sketch from the USBHostGiga library it receives, the keystrokes and prints them out in the Serial monitor.
If I instead run a similar test using this library it does not.
I added debug output to the keyboard class... So I know it is being called. Debug shows:
The input code for the Serial class is not receiving any data. I have a Logic Analyzer attached and it is showing the device is sending data:
And using my USB Analyzers for the Saleae, we see the following messages: <html xmlns:v="urn:schemas-microsoft-com:vml"
xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40">
0.832053362 | SETUP | 0x0 | 0x0 | [GET_DESCRIPTOR - DEVICE #:0 I:0x0 L:0x8] | 0x80 0x6 0x0 0x1 0x0 0x0 0x8 0x0 | -- | -- | -- | -- | -- | -- | -- 0.832366214 | IN | 0x0 | 0x0 | | 0x12 0x1 0x10 0x1 0x0 0x0 0x0 0x8 | 0.832567682 | SETUP | 0x0 | 0x0 | SET_ADDRESS I:0x0 L:0x0] | 0x0 0x5 0x1 0x0 0x0 0x0 0x0 0x0 | 0.83507364 | SETUP | 0x0 | 0x1 | [GET_DESCRIPTOR - DEVICE #:0 I:0x0 L:0x8] | 0x80 0x6 0x0 0x1 0x0 0x0 0x8 0x0 | 0.835433222 | IN | 0x0 | 0x1 | | 0x12 0x1 0x10 0x1 0x0 0x0 0x0 0x8 | 5.247817658 | SETUP | 0x0 | 0x1 | [GET_DESCRIPTOR - DEVICE #:0 I:0x0 L:0x12] | 0x80 0x6 0x0 0x1 0x0 0x0 0x12 0x0 | 5.248132034 | IN | 0x0 | 0x1 | | 0x12 0x1 0x10 0x1 0x0 0x0 0x0 0x8 | 5.248332872 | IN | 0x0 | 0x1 | | 0xca 0x4 0x27 0x0 0x18 0x1 0x1 0x2 | 5.24848434 | IN | 0x0 | 0x1 | | 0x0 0x1 | | | | 5.248818002 | SETUP | 0x0 | 0x1 | [GET_DESCRIPTOR - CONFIG #:0 I:0x0 L:0x9] | 0x80 0x6 0x0 0x2 0x0 0x0 0x9 0x0 | 5.249177614 | IN | 0x0 | 0x1 | | 0x9 0x2 0x3b 0x0 0x2 0x1 0x0 0xa0 | 5.249328152 | IN | 0x0 | 0x1 | | 0x32 | | | | 5.24949202 | SETUP | 0x0 | 0x1 | [GET_DESCRIPTOR - CONFIG #:0 I:0x0 L:0x3b] | 0x80 0x6 0x0 0x2 0x0 0x0 0x3b 0x0 | 5.249817728 | IN | 0x0 | 0x1 | | 0x9 0x2 0x3b 0x0 0x2 0x1 0x0 0xa0 | 5.250017522 | IN | 0x0 | 0x1 | | 0x32 0x9 0x4 0x0 0x0 0x1 0x3 0x1 | 5.250218148 | IN | 0x0 | 0x1 | | 0x1 0x0 0x9 0x21 0x10 0x1 0x0 0x1 | 5.250416976 | IN | 0x0 | 0x1 | | 0x22 0x41 0x0 0x7 0x5 0x81 0x3 0x8 | 5.25081862 | IN | 0x0 | 0x1 | | 0x0 0x18 0x9 0x4 0x1 0x0 0x1 0x3 | 5.251016772 | IN | 0x0 | 0x1 | | 0x0 0x0 0x0 0x9 0x21 0x10 0x1 0x0 | 5.251216778 | IN | 0x0 | 0x1 | | 0x1 0x22 0x9f 0x0 0x7 0x5 0x82 0x3 | 5.25141592 | IN | 0x0 | 0x1 | | 0x8 0x0 0xa | | | 5.257467042 | SETUP | 0x0 | 0x1 | [SET_CONFIGURATION I:0x0 L:0x0] | 0x0 0x9 0x1 0x0 0x0 0x0 0x0 0x0 | 5.762888028 | IN | 0x1 | 0x1 | | 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 | 5.85990304 | IN | 0x1 | 0x1 | | 0x0 0x0 0x38 0x0 0x0 0x0 0x0 0x0 | 5.952923144 | IN | 0x1 | 0x1 | | 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 | 6.079945542 | IN | 0x1 | 0x1 | | 0x0 0x0 0x38 0x0 0x0 0x0 0x0 0x0 | 6.228969228 | IN | 0x1 | 0x1 | | 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 | 6.351984988 | IN | 0x1 | 0x1 | | 0x0 0x0 0x38 0x0 0x0 0x0 0x0 0x0 | 6.476997196 | IN | 0x1 | 0x1 | | 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 | 6.59402179 | IN | 0x1 | 0x1 | | 0x0 0x0 0x38 0x0 0x0 0x0 0x0 0x0 | 6.71103967 | IN | 0x1 | 0x1 | | 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 | 6.816071866 | IN | 0x1 | 0x1 | | 0x0 0x0 0x10 0x0 0x0 0x0 0x0 0x0 | 7.007111472 | IN | 0x1 | 0x1 | | 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 |