Sorry I know slightly off topic of Serial... But tried keyboard.
So far a quick and dirty version for the MBED5...
/*
USBHost Keyboard test
The circuit:
- Arduino GIGA
This example code is in the public domain.
*/
#include <Arduino_USBHostMbed5.h>
#include <USBHostHID/USBHostKeyboard.h>
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);
}
Is not seeing either of the two Dell keyboards I tried. Maybe I am missing some step to intialize the system... Although don't see much different in the Directory list example...
I also tried it with the KeyboardGiga.ino example and it sees one of the two keyboards. The one that it sees (Using HID device sketch I have for teensy.....):
USB HID Device Info Program
This Sketch shows information about plugged in HID devices
*** You can control the output by simple character input to Serial ***
R - Turns on or off showing the raw data
C - Toggles showing changed data only on or off
<anything else> - toggles showing the Hid formatted breakdown of the data
USBDeviceInfo claim this=2000CF64
****************************************
** Device Level **
vid=413C
pid=2113
bDeviceClass = 0
bDeviceSubClass = 0
bDeviceProtocol = 0
09 04 00 00 01 03 01 01 00 09 21 11 01 00 01 22 41 00 07 05 81 03 08 00 18 09 04 01 00 01 03 00
00 00 09 21 11 01 00 01 22 6D 00 07 05 82 03 08 00 30
USBDeviceInfo claim this=2000CF64
****************************************
** Interface Level **
09 04 00 00 01 03 01 01 00 09 21 11 01 00 01 22 41 00 07 05 81 03 08 00 18 09 04 01 00 01 03 00
00 00 09 21 11 01 00 01 22 6D 00 07 05 82 03 08 00 30
bInterfaceNumber = 0
number end points = 1
bInterfaceClass = 3
bInterfaceSubClass = 1
HID (BOOT)
bInterfaceProtocol = 1
Keyboard
report descriptor size = 65
endpoint = 81
attributes = 3 Interrupt
size = 8
interval = 24
USBDeviceInfo claim this=2000CF64
****************************************
** Interface Level **
09 04 01 00 01 03 00 00 00 09 21 11 01 00 01 22 6D 00 07 05 82 03 08 00 30
bInterfaceNumber = 1
number end points = 1
bInterfaceClass = 3
bInterfaceSubClass = 0
HID
bInterfaceProtocol = 0
None
report descriptor size = 109
endpoint = 82
attributes = 3 Interrupt
size = 8
interval = 48
*** Device HID1 413c:2113 - connected ***
product: Dell KB216 Wired Keyboard
*** Device HID2 413c:2113 - connected ***
product: Dell KB216 Wired Keyboard
HIDDumpController(1 : 0x20004220 : 0x20009680) Claim: 413c:2113 usage: 10006 SubClass: 1 Protocol: 1 - Yes
>> Boot Keyboard - Send SET_IDLE <<
HID Report Descriptor (0x20009a18) size: 65
05 01 // Usage Page(1) - Generic Desktop
09 06 // Usage(6) -(Keyboard)
A1 01 // Collection(1) top Usage(10000)
05 07 // Usage Page(7) - Keycode
19 E0 // Usage Minimum(e0) - (Left Control)
29 E7 // Usage Maximum(e7) - (Right GUI)
15 00 // Logical Minimum(0)
25 01 // Logical maximum(1)
75 01 // Report Size(1)
95 08 // Report Count(8)
81 02 // Input(2) // (Data, Variable, Absolute)
95 01 // Report Count(1)
75 08 // Report Size(8)
81 01 // Input(1) // (Constant, Array, Absolute)
95 03 // Report Count(3)
75 01 // Report Size(1)
05 08 // Usage Page(8) - LEDs
19 01 // Usage Minimum(1) -
29 03 // Usage Maximum(3) -
91 02 // Output(2) // (Data, Variable, Absolute)
95 01 // Report Count(1)
75 05 // Report Size(5)
91 01 // Output(1) // (Constant, Array, Absolute)
95 06 // Report Count(6)
75 08 // Report Size(8)
15 00 // Logical Minimum(0)
26 FF 00 // Logical maximum(ff)
05 07 // Usage Page(7) - Keycode
19 00 // Usage Minimum(0) - (Keycode 0)
2A FF 00 // Usage Maximum(ff) - (Keycode 255)
81 00 // Input(0) // (Data, Array, Absolute)
C0 // End Collection
*** HID Device hdc1 413c: 2113 - connected ***
product: Dell KB216 Wired Keyboard
HIDDumpController(1 : 0x20004220 : 0x20009dc0) Claim: 413c:2113 usage: 10080 SubClass: 0 Protocol: 0 - NO (Usage: 10006)
HIDDumpController(2 : 0x20005300 : 0x20009dc0) Claim: 413c:2113 usage: 10080 SubClass: 0 Protocol: 0 - Yes
HID Report Descriptor (0x2000a158) size: 109
05 01 // Usage Page(1) - Generic Desktop
09 80 // Usage(80) -(?)
A1 01 // Collection(1) top Usage(10080)
85 01 // Report ID(1)
19 81 // Usage Minimum(81) - (System Power Down)
29 83 // Usage Maximum(83) - (System Wake Up)
15 00 // Logical Minimum(0)
25 01 // Logical maximum(1)
75 01 // Report Size(1)
95 03 // Report Count(3)
81 02 // Input(2) // (Data, Variable, Absolute)
75 05 // Report Size(5)
95 01 // Report Count(1)
81 01 // Input(1) // (Constant, Array, Absolute)
C0 // End Collection
05 0C // Usage Page(c) - Consumer
09 01 // Usage(1) -(Consumer Controls)
A1 01 // Collection(1) top Usage(c0000)
85 02 // Report ID(2)
0A B5 00 // Usage(b5) -(Scan Next Track)
0A B6 00 // Usage(b6) -(Scan Previous Track)
0A B7 00 // Usage(b7) -(Stop)
0A 83 01 // Usage(183) -(AL Consumer Control Configuration)
0A CD 00 // Usage(cd) -(Pause/Continue)
0A E9 00 // Usage(e9) -(Volume Up)
0A EA 00 // Usage(ea) -(Volume Down)
0A E2 00 // Usage(e2) -(Mute)
0A 24 02 // Usage(224) -(AC Back)
0A 8A 01 // Usage(18a) -(AL Email Reader)
0A 25 02 // Usage(225) -(AC Forward)
0A 23 02 // Usage(223) -(AC Home)
0A 21 02 // Usage(221) -(AC Search)
0A 26 02 // Usage(226) -(AC Stop)
0A 27 02 // Usage(227) -(AC Refresh)
0A 2A 02 // Usage(22a) -(AC Bookmarks)
0A 92 01 // Usage(192) -(AL Calculator)
0A 94 01 // Usage(194) -(AL Local Machine Browser)
09 B8 // Usage(b8) -(Eject)
0A A7 01 // Usage(1a7) -(?)
75 01 // Report Size(1)
95 14 // Report Count(14)
81 02 // Input(2) // (Data, Variable, Absolute)
75 01 // Report Size(1)
95 04 // Report Count(4)
81 01 // Input(1) // (Constant, Array, Absolute)
C0 // End Collection
HIDDumpController(1 : 0x20004220 : 0x20009dc0) Claim: 413c:2113 usage: c0001 SubClass: 0 Protocol: 0 - NO (Usage: 10006)
HIDDumpController(2 : 0x20005300 : 0x20009dc0) Claim: 413c:2113 usage: c0001 SubClass: 0 Protocol: 0 - NO (Usage: 10080)
HIDDumpController(3 : 0x200063e0 : 0x20009dc0) Claim: 413c:2113 usage: c0001 SubClass: 0 Protocol: 0 - Yes
HID Report Descriptor (0x2000a158) size: 109
05 01 // Usage Page(1) - Generic Desktop
09 80 // Usage(80) -(?)
A1 01 // Collection(1) top Usage(10080)
85 01 // Report ID(1)
19 81 // Usage Minimum(81) - (System Power Down)
29 83 // Usage Maximum(83) - (System Wake Up)
15 00 // Logical Minimum(0)
25 01 // Logical maximum(1)
75 01 // Report Size(1)
95 03 // Report Count(3)
81 02 // Input(2) // (Data, Variable, Absolute)
75 05 // Report Size(5)
95 01 // Report Count(1)
81 01 // Input(1) // (Constant, Array, Absolute)
C0 // End Collection
05 0C // Usage Page(c) - Consumer
09 01 // Usage(1) -(Consumer Controls)
A1 01 // Collection(1) top Usage(c0000)
85 02 // Report ID(2)
0A B5 00 // Usage(b5) -(Scan Next Track)
0A B6 00 // Usage(b6) -(Scan Previous Track)
0A B7 00 // Usage(b7) -(Stop)
0A 83 01 // Usage(183) -(AL Consumer Control Configuration)
0A CD 00 // Usage(cd) -(Pause/Continue)
0A E9 00 // Usage(e9) -(Volume Up)
0A EA 00 // Usage(ea) -(Volume Down)
0A E2 00 // Usage(e2) -(Mute)
0A 24 02 // Usage(224) -(AC Back)
0A 8A 01 // Usage(18a) -(AL Email Reader)
0A 25 02 // Usage(225) -(AC Forward)
0A 23 02 // Usage(223) -(AC Home)
0A 21 02 // Usage(221) -(AC Search)
0A 26 02 // Usage(226) -(AC Stop)
0A 27 02 // Usage(227) -(AC Refresh)
0A 2A 02 // Usage(22a) -(AC Bookmarks)
0A 92 01 // Usage(192) -(AL Calculator)
0A 94 01 // Usage(194) -(AL Local Machine Browser)
09 B8 // Usage(b8) -(Eject)
0A A7 01 // Usage(1a7) -(?)
75 01 // Report Size(1)
95 14 // Report Count(14)
81 02 // Input(2) // (Data, Variable, Absolute)
75 01 // Report Size(1)
95 04 // Report Count(4)
81 01 // Input(1) // (Constant, Array, Absolute)
C0 // End Collection
*** HID Device hdc2 413c: 2113 - connected ***
product: Dell KB216 Wired Keyboard
*** HID Device hdc3 413c: 2113 - connected ***
product: Dell KB216 Wired Keyboard
Side notes on testing with this keyboard:
1)If I unplug this device from the GIGA, after the sketch starts, will crash the MBED OS...
2) Does not respond to any of the multimedia or system keys
3) Does not handle things like capslock and likewise the led states.
The one that the GIGA keyboard sketch does not respond to:
*** Device Hub1 413c:1004 - connected ***
manufacturer: Dell
product: Dell USB Keyboard Hub
USBDeviceInfo claim this=2000CF64
****************************************
** Device Level **
vid=413C
pid=2006
bDeviceClass = 0
bDeviceSubClass = 0
bDeviceProtocol = 0
09 04 00 00 01 03 01 01 02 09 21 10 01 00 01 22 41 00 07 05 81 03 08 00 0A 09 04 01 00 01 03 00
00 02 09 21 10 01 00 01 22 8E 00 07 05 82 03 04 00 FF
*** Device HID1 413c:2006 - connected ***
manufacturer: Dell
product: Dell USB Keyboard Hub
*** Device HID2 413c:2006 - connected ***
manufacturer: Dell
product: Dell USB Keyboard Hub
HIDDumpController(1 : 0x20004220 : 0x20009680) Claim: 413c:2006 usage: 10006 SubClass: 1 Protocol: 1 - Yes
>> Boot Keyboard - Send SET_IDLE <<
HID Report Descriptor (0x20009a18) size: 65
05 01 // Usage Page(1) - Generic Desktop
09 06 // Usage(6) -(Keyboard)
A1 01 // Collection(1) top Usage(10000)
05 07 // Usage Page(7) - Keycode
19 E0 // Usage Minimum(e0) - (Left Control)
29 E7 // Usage Maximum(e7) - (Right GUI)
15 00 // Logical Minimum(0)
25 01 // Logical maximum(1)
75 01 // Report Size(1)
95 08 // Report Count(8)
81 02 // Input(2) // (Data, Variable, Absolute)
95 01 // Report Count(1)
75 08 // Report Size(8)
81 01 // Input(1) // (Constant, Array, Absolute)
95 05 // Report Count(5)
75 01 // Report Size(1)
05 08 // Usage Page(8) - LEDs
19 01 // Usage Minimum(1) -
29 05 // Usage Maximum(5) -
91 02 // Output(2) // (Data, Variable, Absolute)
95 01 // Report Count(1)
75 03 // Report Size(3)
91 01 // Output(1) // (Constant, Array, Absolute)
95 06 // Report Count(6)
75 08 // Report Size(8)
15 00 // Logical Minimum(0)
26 FF 00 // Logical maximum(ff)
05 07 // Usage Page(7) - Keycode
19 00 // Usage Minimum(0) - (Keycode 0)
2A FF 00 // Usage Maximum(ff) - (Keycode 255)
81 00 // Input(0) // (Data, Array, Absolute)
C0 // End Collection
*** HID Device hdc1 413c: 2006 - connected ***
manufacturer: Dell
product: Dell USB Keyboard Hub
HIDDumpController(1 : 0x20004220 : 0x20009dc0) Claim: 413c:2006 usage: c0001 SubClass: 0 Protocol: 0 - NO (Usage: 10006)
HIDDumpController(2 : 0x20005300 : 0x20009dc0) Claim: 413c:2006 usage: c0001 SubClass: 0 Protocol: 0 - Yes
HID Report Descriptor (0x2000a158) size: 142
05 0C // Usage Page(c) - Consumer
09 01 // Usage(1) -(Consumer Controls)
A1 01 // Collection(1) top Usage(c0000)
85 01 // Report ID(1)
09 E0 // Usage(e0) -(Volume)
15 E8 // Logical Minimum(e8)
25 18 // Logical maximum(18)
75 07 // Report Size(7)
95 01 // Report Count(1)
81 06 // Input(6) // (Data, Variable, Relative)
15 00 // Logical Minimum(0)
25 01 // Logical maximum(1)
75 01 // Report Size(1)
09 E2 // Usage(e2) -(Mute)
81 06 // Input(6) // (Data, Variable, Relative)
C0 // End Collection
05 01 // Usage Page(1) - Generic Desktop
09 80 // Usage(80) -(?)
A1 01 // Collection(1) top Usage(10080)
85 02 // Report ID(2)
15 00 // Logical Minimum(0)
25 01 // Logical maximum(1)
75 01 // Report Size(1)
95 03 // Report Count(3)
09 82 // Usage(82) -(System Sleep)
09 82 // Usage(82) -(System Sleep)
09 82 // Usage(82) -(System Sleep)
81 06 // Input(6) // (Data, Variable, Relative)
95 05 // Report Count(5)
81 01 // Input(1) // (Constant, Array, Absolute)
C0 // End Collection
05 0C // Usage Page(c) - Consumer
09 01 // Usage(1) -(Consumer Controls)
A1 01 // Collection(1) top Usage(c0000)
85 03 // Report ID(3)
15 00 // Logical Minimum(0)
25 01 // Logical maximum(1)
75 01 // Report Size(1)
95 01 // Report Count(1)
0A 24 02 // Usage(224) -(AC Back)
81 06 // Input(6) // (Data, Variable, Relative)
0A 25 02 // Usage(225) -(AC Forward)
81 06 // Input(6) // (Data, Variable, Relative)
0A 26 02 // Usage(226) -(AC Stop)
81 06 // Input(6) // (Data, Variable, Relative)
0A 27 02 // Usage(227) -(AC Refresh)
81 06 // Input(6) // (Data, Variable, Relative)
0A 23 02 // Usage(223) -(AC Home)
81 06 // Input(6) // (Data, Variable, Relative)
0A 8A 01 // Usage(18a) -(AL Email Reader)
81 06 // Input(6) // (Data, Variable, Relative)
0A 94 01 // Usage(194) -(AL Local Machine Browser)
81 06 // Input(6) // (Data, Variable, Relative)
0A 92 01 // Usage(192) -(AL Calculator)
81 06 // Input(6) // (Data, Variable, Relative)
09 B5 // Usage(b5) -(Scan Next Track)
81 06 // Input(6) // (Data, Variable, Relative)
09 B6 // Usage(b6) -(Scan Previous Track)
81 06 // Input(6) // (Data, Variable, Relative)
09 CD // Usage(cd) -(Pause/Continue)
81 06 // Input(6) // (Data, Variable, Relative)
09 B7 // Usage(b7) -(Stop)
81 06 // Input(6) // (Data, Variable, Relative)
0A 83 01 // Usage(183) -(AL Consumer Control Configuration)
81 06 // Input(6) // (Data, Variable, Relative)
95 0B // Report Count(b)
81 01 // Input(1) // (Constant, Array, Absolute)
C0 // End Collection
HIDDumpController(1 : 0x20004220 : 0x20009dc0) Claim: 413c:2006 usage: 10080 SubClass: 0 Protocol: 0 - NO (Usage: 10006)
HIDDumpController(2 : 0x20005300 : 0x20009dc0) Claim: 413c:2006 usage: 10080 SubClass: 0 Protocol: 0 - NO (Usage: c0001)
HIDDumpController(3 : 0x200063e0 : 0x20009dc0) Claim: 413c:2006 usage: 10080 SubClass: 0 Protocol: 0 - Yes
HID Report Descriptor (0x2000a158) size: 142
05 0C // Usage Page(c) - Consumer
09 01 // Usage(1) -(Consumer Controls)
A1 01 // Collection(1) top Usage(c0000)
85 01 // Report ID(1)
09 E0 // Usage(e0) -(Volume)
15 E8 // Logical Minimum(e8)
25 18 // Logical maximum(18)
75 07 // Report Size(7)
95 01 // Report Count(1)
81 06 // Input(6) // (Data, Variable, Relative)
15 00 // Logical Minimum(0)
25 01 // Logical maximum(1)
75 01 // Report Size(1)
09 E2 // Usage(e2) -(Mute)
81 06 // Input(6) // (Data, Variable, Relative)
C0 // End Collection
05 01 // Usage Page(1) - Generic Desktop
09 80 // Usage(80) -(?)
A1 01 // Collection(1) top Usage(10080)
85 02 // Report ID(2)
15 00 // Logical Minimum(0)
25 01 // Logical maximum(1)
75 01 // Report Size(1)
95 03 // Report Count(3)
09 82 // Usage(82) -(System Sleep)
09 82 // Usage(82) -(System Sleep)
09 82 // Usage(82) -(System Sleep)
81 06 // Input(6) // (Data, Variable, Relative)
95 05 // Report Count(5)
81 01 // Input(1) // (Constant, Array, Absolute)
C0 // End Collection
05 0C // Usage Page(c) - Consumer
09 01 // Usage(1) -(Consumer Controls)
A1 01 // Collection(1) top Usage(c0000)
85 03 // Report ID(3)
15 00 // Logical Minimum(0)
25 01 // Logical maximum(1)
75 01 // Report Size(1)
95 01 // Report Count(1)
0A 24 02 // Usage(224) -(AC Back)
81 06 // Input(6) // (Data, Variable, Relative)
0A 25 02 // Usage(225) -(AC Forward)
81 06 // Input(6) // (Data, Variable, Relative)
0A 26 02 // Usage(226) -(AC Stop)
81 06 // Input(6) // (Data, Variable, Relative)
0A 27 02 // Usage(227) -(AC Refresh)
81 06 // Input(6) // (Data, Variable, Relative)
0A 23 02 // Usage(223) -(AC Home)
81 06 // Input(6) // (Data, Variable, Relative)
0A 8A 01 // Usage(18a) -(AL Email Reader)
81 06 // Input(6) // (Data, Variable, Relative)
0A 94 01 // Usage(194) -(AL Local Machine Browser)
81 06 // Input(6) // (Data, Variable, Relative)
0A 92 01 // Usage(192) -(AL Calculator)
81 06 // Input(6) // (Data, Variable, Relative)
09 B5 // Usage(b5) -(Scan Next Track)
81 06 // Input(6) // (Data, Variable, Relative)
09 B6 // Usage(b6) -(Scan Previous Track)
81 06 // Input(6) // (Data, Variable, Relative)
09 CD // Usage(cd) -(Pause/Continue)
81 06 // Input(6) // (Data, Variable, Relative)
09 B7 // Usage(b7) -(Stop)
81 06 // Input(6) // (Data, Variable, Relative)
0A 83 01 // Usage(183) -(AL Consumer Control Configuration)
81 06 // Input(6) // (Data, Variable, Relative)
95 0B // Report Count(b)
81 01 // Input(1) // (Constant, Array, Absolute)
C0 // End Collection
HIDDumpController(1 : 0x20004220 : 0x20009dc0) Claim: 413c:2006 usage: c0001 SubClass: 0 Protocol: 0 - NO (Usage: 10006)
HIDDumpController(2 : 0x20005300 : 0x20009dc0) Claim: 413c:2006 usage: c0001 SubClass: 0 Protocol: 0 - Yes
*** HID Device hdc2 413c: 2006 - connected ***
manufacturer: Dell
product: Dell USB Keyboard Hub
*** HID Device hdc3 413c: 2006 - connected ***
manufacturer: Dell
product: Dell USB Keyboard Hub
Now I remember, this keyboard has a built-in HUB, and the actual keyboard object is logically connected to one of the ports of the internal hub.
But now probably should try some Serial objects, to see how they are supported. As that is the title of this thread.