Hi @KurtE, I left a comment on that issue with a possible solution to the truncated device descriptor.
Thanks,
I also just added new issue:
GIGA R1: PL2303 USB Serial Adapter - faulting in USBDeviceConnected::getEndpoint · Issue #34 · arduino-libraries/Arduino_USBHostMbed5 (github.com)
For the PL2303 fault
Closed this one out. Looks like it was caused by some debug code I added...
Keeping fingers crossed.
EDIT: Although it did not catch it, but I do think some of the code could be made more robust:
For example:
USBEndpoint * USBDeviceConnected::getEndpoint(uint8_t intf_nb, ENDPOINT_TYPE type, ENDPOINT_DIRECTION dir, uint8_t index) {
if (intf_nb >= MAX_INTF) {
return NULL;
}
for (int i = 0; i < MAX_ENDPOINT_PER_INTERFACE; i++) {
if ((intf[intf_nb].ep[i]->getType() == type) && (intf[intf_nb].ep[i]->getDir() == dir)) {
...
If I call it for a second endpoint but only one was found, it will walk into the 2nd one which will be a nullptr and fault on the call: intf[intf_nb].ep[i]->getType()
Decided to do more debugging of the gamepad sketch. Started comparing the output from Teensy USBHost and the GIGA USBHost to see whats going on. Using the same PS4 attached to both:
Device Descriptor - Matches:
**Teensy**
Device Descriptor:
*12 01 00 02 00 00 00 40 4C 05 C4 05 00 01 01 02 00 01*
VendorID = 054C, ProductID = 05C4, Version = 0100
Class/Subclass/Protocol = 0 / 0 / 0
Number of Configurations = 1
**GIGA**:
CONTROL READ SUCCESS [18 bytes transferred]
*12 01 00 02 00 00 00 40 4C 05 C4 05 00 01 01 02 00 01*
CLASS: 00 VID: 054C PID: 05C4
Configuration Descriptor:
**Teensy:**
*09 02 29 00 01 01 00 C0 FA*
NumInterfaces = 1
ConfigurationValue = 1
*09 04 00 00 02 03 00 00 00*
Interface = 0
Number of endpoints = 2
Class/Subclass/Protocol = 3(HID) / 0 / 0
*09 21 11 01 00 01 22 F3 01*
HID, 1 report descriptor
*07 05 84 03 40 00 05*
Endpoint = 4 IN
Type = Interrupt
Max Size = 64
Polling Interval = 5
*07 05 03 03 40 00 05*
Endpoint = 3 OUT
Type = Interrupt
Max Size = 64
Polling Interval = 5
**GIGA:**
*09 02 29 00 01 01 00 C0 FA 09 04 00 00 02 03 00 00 00 09 21 11 01 00 01 22 F3 01 07 05 84 03 40 00 05 07 05 03 03 40 00 05*
[USB_DBG: d:\Users\Merli\Documents\Arduino\libraries\Arduino_USBHostMbed5\src\USBHost\USBHost.cpp:1021]dev: 0x2400c6bc has 1 intf
[USB_DBG: d:\Users\Merli\Documents\Arduino\libraries\Arduino_USBHostMbed5\src\USBHost\USBHost.cpp:1030]ADD INTF 0 on device 0x2400c6bc: class: 3, subclass: 0, proto: 0
[USB_DBG: d:\Users\Merli\Documents\Arduino\libraries\Arduino_USBHostMbed5\src\USBHost\USBHost.cpp:610]USBEndpoint created (0x2400c0ac): type: 3, dir: 2, size: 64, addr: 4, state: USB_TYPE_IDLE
[USB_DBG: d:\Users\Merli\Documents\Arduino\libraries\Arduino_USBHostMbed5\src\USBHost\USBHost.cpp:1049]ADD USBEndpoint 0x2400c0ac, on interf 0 on device 0x2400c6bc
[USB_DBG: d:\Users\Merli\Documents\Arduino\libraries\Arduino_USBHostMbed5\src\USBHost\USBHost.cpp:982]Set configuration 1 on dev: 0x2400c6bc
[USB_TRANSFER: d:\Users\Merli\Documents\Arduino\libraries\Arduino_USBHostMbed5\src\USBHost\USBHost.cpp:1188]----- CONTROL WRITE [dev: 0x2400c6bc - hub: 0 - port: 1] ------
[USB_TRANSFER: d:\Users\Merli\Documents\Arduino\libraries\Arduino_USBHostMbed5\src\USBHost\USBHost.cpp:1202]Control transfer on device: 1
at this point the GIGA finishes up and connects:
[USB_TRANSFER: d:\Users\Merli\Documents\Arduino\libraries\Arduino_USBHostMbed5\src\USBHost\USBHost.cpp:1206]SETUP PACKET:
0 9 1 0 0 0 0 0
[USB_TRANSFER: d:\Users\Merli\Documents\Arduino\libraries\Arduino_USBHostMbed5\src\USBHost\USBHost.cpp:1234]CONTROL setup stage USB_TYPE_IDLE
[USB_TRANSFER: d:\Users\Merli\Documents\Arduino\libraries\Arduino_USBHostMbed5\src\USBHost\USBHost.cpp:1304]CONTROL ack stage USB_TYPE_IDLE
[USB_DBG: d:\Users\Merli\Documents\Arduino\libraries\Arduino_USBHostMbed5\src\USBHost\USBHost.cpp:995]dev 0x2400c6bc is enumerated
[USB_INFO: D:\Users\Merli\Documents\Arduino\Arduino Giga\GamePad\USBHostGamepad.cpp:69]New Gamepad device: VID:054c PID:05c4 [dev: 0x2400c6bc - intf: 0]
New Gamepad device: VID:054c PID:05c4 [dev: 0x2400c6bc - intf: 0][USB_DBG: d:\Users\Merli\Documents\Arduino\libraries\Arduino_USBHostMbed5\src/USBHost/USBHost.h:170]register driver for dev: 0x2400c6bc on intf: 0
[USB_TRANSFER: d:\Users\Merli\Documents\Arduino\libraries\Arduino_USBHostMbed5\src\USBHost\USBHost.cpp:1099]----- INTERRUPT READ [dev: 0x2400c6bc - **Gamepad - hub: 0 - port: 1 - addr: 1 - ep: 84]**------
Dev connected
Gamepad connected
But on the teensy it goes on
USBHub memory usage = 960
USBHub claim_device this=20004C80
HIDParser claim this=20004220
JoystickController claim this=20005040
JoystickController::claim(0x20005040) Dev:0x20006f88 Type:0
JoystickController claim this=20005580
JoystickController::claim(0x20005580) Dev:0x20006f88 Type:0
JoystickController claim this=20005AC0
JoystickController::claim(0x20005ac0) Dev:0x20006f88 Type:0
JoystickController claim this=20006000
JoystickController::claim(0x20006000) Dev:0x20006f88 Type:0
Descriptor 4 = INTERFACE
HIDParser claim this=20004220
bInterfaceNumber = 0
bInterfaceClass = 3
bInterfaceSubClass = 0
bInterfaceProtocol = 0
HID Parser Claim: 09 04 00 00 02 03 00 00 00 09 21 11 01 00 01 22 F3 01 07 05 84 03 40 00 05 07 05 03 03 40 00 05
report descriptor size = 499
Two endpoint HID:
endpoint = 84
size = 64
interval = 5
endpoint = 3
size = 64
interval = 5
new_Pipe
allocate_interrupt_pipe_bandwidth
best_bandwidth = 5, at offset = 0, shift= 0
new_Pipe
allocate_interrupt_pipe_bandwidth
best_bandwidth = 6, at offset = 1, shift= 0
Descriptor 33 = HID
Descriptor 5 = ENDPOINT
Descriptor 5 = ENDPOINT
*** Device HID1 54c:5c4 - connected ***
manufacturer: Sony Computer Entertainment
product: Wireless Controller
control callback (hid)
05 01 09 05 A1 01 85 01 09 30 09 31 09 32 09 35 15 00 26 FF 00 75 08 95 04 81 02 09 39 15 00 25 07 35 00 46 3B 01 65 14 75 04 95 01 81 42 65 00 05 09 19 01 29 0E 15 00 25 01 75 01 95 0E 81 02 06 00 FF 09 20 75 06 95 01 15 00 25 7F 81 02 05 01 09 33 09 34 15 00 26 FF 00 75 08 95 02 81 02 06 00 FF 09 21 95 36 81 02 85 05 09 22 95 1F 91 02 85 04 09 23 95 24 B1 02 85 02 09 24 95 24 B1 02 85 08 09 25 95 03 B1 02 85 10 09 26 95 04 B1 02 85 11 09 27 95 02 B1 02 85 12 06 02 FF 09 21 95 0F B1 02 85 13 09 22 95 16 B1 02 85 14 06 05 FF 09 20 95 10 B1 02 85 15 09 21 95 2C B1 02 06 80 FF 85 80 09 20 95 06 B1 02 85 81 09 21 95 06 B1 02 85 82 09 22 95 05 B1 02 85 83 09 23 95 01 B1 02 85 84 09 24 95 04 B1 02 85 85 09 25 95 06 B1 02 85 86 09 26 95 06 B1 02 85 87 09 27 95 23 B1 02 85 88 09 28 95 22 B1 02 85 89 09 29 95 02 B1 02 85 90 09 30 95 05 B1 02 85 91 09 31 95 03 B1 02 85 92 09 32 95 03 B1 02 85 93 09 33 95 0C B1 02 85 A0 09 40 95 06 B1 02 85 A1 09 41 95 01 B1 02 85 A2 09 42 95 01 B1 02 85 A3 09 43 95 30 B1 02 85 A4 09 44 95 0D B1 02 85 A5 09 45 95 15 B1 02 85 A6 09 46 95 15 B1 02 85 F0 09 47 95 3F B1 02 85 F1 09 48 95 3F B1 02 85 F2 09 49 95 0F B1 02 85 A7 09 4A 95 01 B1 02 85 A8 09 4B 95 01 B1 02 85 A9 09 4C 95 08 B1 02 85 AA 09 4E 95 01 B1 02 85 AB 09 4F 95 39 B1 02 85 AC 09 50 95 39 B1 02 85 AD 09 51 95 0B B1 02 85 AE 09 52 95 01 B1 02 85 AF 09 53 95 02 B1 02 85 B0 09 54 95 3F B1 02 85 B1 09 55 95 02 B1 02 85 B2 09 56 95 02 B1 02 85 B3 09 55 95 3F B1 02 85 B4 09 55 95 3F B1 02 C0
mesg = 22000681
got report descriptor
Found top level collection 10005
find_driver
driver 2000504C
JoystickController::claim_collection(0x20005040) Driver:0x20004220(0 0) Dev:0x20006f88 Top:10005
Match PID/VID: 10
JoystickController::claim_collection joystickType_=2
JoystickController claim collection
*** HID Device joystick[0H] 54c:5c4 - connected ***
manufacturer: Sony Computer Entertainment
product: Wireless Controller
Then it starts getting and parsing the report data.
Am I crazy or is it not getting additional endpoints? EDIT: looks like it only picking up endpoint 84
EDIT: Think this might go along with what @KurtE mentioning in the previous post
Maybe making progress on getting the GPS to work... Maybe...
I am trying now to do the extra steps once the initial connect code finishes, to do the PL2303 specific initialization to be done...
And theirs is a PIA!
First here is a capture of the USB traffic that I captured on Teensy Micromod using @Merlin513 sketch from back when... This is from my extended Saleae USB analyzer, plus an HLA to filter the data to setup and IN and OUT messages:
1.923350774 ; SETUP ; 0x0 ; 0x0 ; [GET_DESCRIPTOR - DEVICE #:0 I:0x0 L:0x8] ; 0x80 0x6 0x0 0x1 0x0 0x0 0x8 0x0
1.923365774 ; IN ; 0x0 ; 0x0 ; ; 0x12 0x1 0x10 0x1 0x0 0x0 0x0 0x40
1.924428508 ; SETUP ; 0x0 ; 0x0 ; SET_ADDRESS I:0x0 L:0x0] ; 0x0 0x5 0x1 0x0 0x0 0x0 0x0 0x0
1.925428538 ; SETUP ; 0x0 ; 0x1 ; [GET_DESCRIPTOR - DEVICE #:0 I:0x0 L:0x12] ; 0x80 0x6 0x0 0x1 0x0 0x0 0x12 0x0
1.925443504 ; IN ; 0x0 ; 0x1 ; SET_PROTOCOL(0x0xb) ; 0x12 0x1 0x10 0x1 0x0 0x0 0x0 0x40 0x7b 0x6 0x3 0x23 0x0 0x4 0x1 0x2 0x0 0x1
1.92642857 ; SETUP ; 0x0 ; 0x1 ; [GET_DESCRIPTOR - STRING #:0 I:0x0 L:0x7fc] ; 0x80 0x6 0x0 0x3 0x0 0x0 0xfc 0x7
1.926443668 ; IN ; 0x0 ; 0x1 ; ; 0x4 0x3 0x9 0x4
1.9274286 ; SETUP ; 0x0 ; 0x1 ; [GET_DESCRIPTOR - STRING #:1 I:0x409 L:0x7fc] ; 0x80 0x6 0x1 0x3 0x9 0x4 0xfc 0x7
1.927443698 ; IN ; 0x0 ; 0x1 ; GET_PROTOCOL(0x0xc) ; 0x34 0x3 0x50 0x0 0x72 0x0 0x6f 0x0 0x6c 0x0 0x69 0x0 0x66 0x0 0x69 0x0 0x63 0x0 0x20 0x0 0x54 0x0 0x65 0x0 0x63 0x0 0x68 0x0 0x6e 0x0 0x6f 0x0 0x6c 0x0 0x6f 0x0 0x67 0x0 0x79 0x0 0x20 0x0 0x49 0x0 0x6e 0x0 0x63 0x0 0x2e 0x0 0x20 0x0
1.92842863 ; SETUP ; 0x0 ; 0x1 ; [GET_DESCRIPTOR - STRING #:2 I:0x409 L:0x7fc] ; 0x80 0x6 0x2 0x3 0x9 0x4 0xfc 0x7
1.928443694 ; IN ; 0x0 ; 0x1 ; 0x2D(0x0xd) ; 0x30 0x3 0x55 0x0 0x53 0x0 0x42 0x0 0x2d 0x0 0x53 0x0 0x65 0x0 0x72 0x0 0x69 0x0 0x61 0x0 0x6c 0x0 0x20 0x0 0x43 0x0 0x6f 0x0 0x6e 0x0 0x74 0x0 0x72 0x0 0x6f 0x0 0x6c 0x0 0x6c 0x0 0x65 0x0 0x72 0x0 0x20 0x0 0x44 0x0
1.929428726 ; SETUP ; 0x0 ; 0x1 ; [GET_DESCRIPTOR - CONFIG #:0 I:0x0 L:0x9] ; 0x80 0x6 0x0 0x2 0x0 0x0 0x9 0x0
1.929443724 ; IN ; 0x0 ; 0x1 ; 0x32(0x0x2) ; 0x9 0x2 0x27 0x0 0x1 0x1 0x0 0x80 0x32
1.93042869 ; SETUP ; 0x0 ; 0x1 ; [GET_DESCRIPTOR - CONFIG #:0 I:0x0 L:0x27] ; 0x80 0x6 0x0 0x2 0x0 0x0 0x27 0x0
1.930443722 ; IN ; 0x0 ; 0x1 ; 0x32(0x0x2) ; 0x9 0x2 0x27 0x0 0x1 0x1 0x0 0x80 0x32 0x9 0x4 0x0 0x0 0x3 0xff 0x0 0x0 0x0 0x7 0x5 0x81 0x3 0xa 0x0 0x1 0x7 0x5 0x2 0x2 0x40 0x0 0x0 0x7 0x5 0x83 0x2 0x40 0x0 0x0
1.93142872 ; SETUP ; 0x0 ; 0x1 ; [SET_CONFIGURATION I:0x0 L:0x0] ; 0x0 0x9 0x1 0x0 0x0 0x0 0x0 0x0
1.932428752 ; SETUP ; 0x0 ; 0x1 ; [RT:0xc0 R:0x1 I:0x0 L:0x1] ; 0xc0 0x1 0x84 0x84 0x0 0x0 0x1 0x0
1.9324506820000003 ; IN ; 0x0 ; 0x1 ; ; 0x2
1.93335751 ; SETUP ; 0x0 ; 0x1 ; [RT:0x40 R:0x1 I:0x0 L:0x0] ; 0x40 0x1 0x4 0x4 0x0 0x0 0x0 0x0
1.934357608 ; SETUP ; 0x0 ; 0x1 ; [RT:0xc0 R:0x1 I:0x0 L:0x1] ; 0xc0 0x1 0x84 0x84 0x0 0x0 0x1 0x0
1.9343791740000003 ; IN ; 0x0 ; 0x1 ; ; 0x2
1.935357638 ; SETUP ; 0x0 ; 0x1 ; [RT:0xc0 R:0x1 I:0x0 L:0x1] ; 0xc0 0x1 0x83 0x83 0x0 0x0 0x1 0x0
1.935379272 ; IN ; 0x0 ; 0x1 ; ; 0xff
1.936357634 ; SETUP ; 0x0 ; 0x1 ; [RT:0xc0 R:0x1 I:0x0 L:0x1] ; 0xc0 0x1 0x84 0x84 0x0 0x0 0x1 0x0
1.936379202 ; IN ; 0x0 ; 0x1 ; ; 0x2
1.937357664 ; SETUP ; 0x0 ; 0x1 ; [RT:0x40 R:0x1 I:0x1 L:0x0] ; 0x40 0x1 0x4 0x4 0x1 0x0 0x0 0x0
1.938357696 ; SETUP ; 0x0 ; 0x1 ; [RT:0xc0 R:0x1 I:0x0 L:0x1] ; 0xc0 0x1 0x84 0x84 0x0 0x0 0x1 0x0
1.93837923 ; IN ; 0x0 ; 0x1 ; ; 0x2
1.939357692 ; SETUP ; 0x0 ; 0x1 ; [RT:0xc0 R:0x1 I:0x0 L:0x1] ; 0xc0 0x1 0x83 0x83 0x0 0x0 0x1 0x0
1.939379326 ; IN ; 0x0 ; 0x1 ; ; 0xff
1.94035779 ; SETUP ; 0x0 ; 0x1 ; [RT:0x40 R:0x1 I:0x1 L:0x0] ; 0x40 0x1 0x0 0x0 0x1 0x0 0x0 0x0
1.94135782 ; SETUP ; 0x0 ; 0x1 ; [RT:0x40 R:0x1 I:0x0 L:0x0] ; 0x40 0x1 0x1 0x0 0x0 0x0 0x0 0x0
1.94235785 ; SETUP ; 0x0 ; 0x1 ; [RT:0x40 R:0x1 I:0x24 L:0x0] ; 0x40 0x1 0x2 0x0 0x24 0x0 0x0 0x0
1.94335788 ; SETUP ; 0x0 ; 0x1 ; [RT:0x40 R:0x1 I:0x0 L:0x0] ; 0x40 0x1 0x8 0x0 0x0 0x0 0x0 0x0
1.94435791 ; SETUP ; 0x0 ; 0x1 ; [RT:0x40 R:0x1 I:0x0 L:0x0] ; 0x40 0x1 0x9 0x0 0x0 0x0 0x0 0x0
1.94535794 ; SETUP ; 0x0 ; 0x1 ; I:0x0 L:0x7] ; 0xa1 0x21 0x0 0x0 0x0 0x0 0x7 0x0
1.945379508 ; IN ; 0x0 ; 0x1 ; ; 0x80 0x25 0x0 0x0 0x0 0x0 0x0
1.946365104 ; SETUP ; 0x0 ; 0x1 ; I:0x0 L:0x7] ; 0x21 0x20 0x0 0x0 0x0 0x0 0x7 0x0
1.946386838 ; OUT ; 0x0 ; 0x1 ; ; 0xc0 0x12 0x0 0x0 0x0 0x0 0x8
1.947357968 ; SETUP ; 0x0 ; 0x1 ; [RT:0x40 R:0x1 I:0x0 L:0x0] ; 0x40 0x1 0x0 0x0 0x0 0x0 0x0 0x0
1.948357998 ; SETUP ; 0x0 ; 0x1 ; I:0x0 L:0x7] ; 0xa1 0x21 0x0 0x0 0x0 0x0 0x7 0x0
1.948379566 ; IN ; 0x0 ; 0x1 ; ; 0xc0 0x12 0x0 0x0 0x0 0x0 0x8
1.948777244 ; IN ; 0x3 ; 0x1 ; ; 0xa6
1.949430534 ; SETUP ; 0x0 ; 0x1 ; I:0x0 L:0x0] ; 0x21 0x22 0x3 0x0 0x0 0x0 0x0 0x0
1.950358192 ; SETUP ; 0x0 ; 0x1 ; I:0x0 L:0x0] ; 0x21 0x22 0x3 0x0 0x0 0x0 0x0 0x0
1.951124218 ; IN ; 0x3 ; 0x1 ; ; 0x36
1.953351684 ; IN ; 0x3 ; 0x1 ; ; 0x56
1.955916164 ; IN ; 0x3 ; 0x1 ; ; 0x6b
1.95877048 ; IN ; 0x3 ; 0x1 ; ; 0xa
3.36141567 ; IN ; 0x3 ; 0x1 ; ; 0x24
3.36377051 ; IN ; 0x3 ; 0x1 ; ; 0x47
3.366001542 ; IN ; 0x3 ; 0x1 ; ; 0x50
3.368394582 ; IN ; 0x3 ; 0x1 ; ; 0x47
3.370582784 ; IN ; 0x3 ; 0x1 ; ; 0x47
3.372959122 ; IN ; 0x3 ; 0x1 ; ; 0x41
3.375168354 ; IN ; 0x3 ; 0x1 ; ; 0x2c
3.37745869 ; IN ; 0x3 ; 0x1 ; ; 0x32
3.3797709960000004 ; IN ; 0x3 ; 0x1 ; ; 0x32
3.382044562 ; IN ; 0x3 ; 0x1 ; ; 0x34
3.384395068 ; IN ; 0x3 ; 0x1 ; ; 0x39
3.3866329 ; IN ; 0x3 ; 0x1 ; ; 0x34
3.388959608 ; IN ; 0x3 ; 0x1 ; ; 0x30
3.391211472 ; IN ; 0x3 ; 0x1 ; ; 0x2e
3.39358348 ; IN ; 0x3 ; 0x1 ; ; 0x39
3.395799912 ; IN ; 0x3 ; 0x1 ; ; 0x31
3.398147818 ; IN ; 0x3 ; 0x1 ; ; 0x34
3.400395552 ; IN ; 0x3 ; 0x1 ; ; 0x2c
3.402675886 ; IN ; 0x3 ; 0x1 ; ; 0x2c
3.404960092 ; IN ; 0x3 ; 0x1 ; ; 0x2c
3.40724746 ; IN ; 0x3 ; 0x1 ; ; 0x2c
3.409583966 ; IN ; 0x3 ; 0x1 ; ; 0x2c
3.411835832 ; IN ; 0x3 ; 0x1 ; ; 0x30
3.414148304 ; IN ; 0x3 ; 0x1 ; ; 0x2c
3.41641727 ; IN ; 0x3 ; 0x1 ; ; 0x30
3.418772178 ; IN ; 0x3 ; 0x1 ; ; 0x30
3.42099601 ; IN ; 0x3 ; 0x1 ; ; 0x2c
3.42339625 ; IN ; 0x3 ; 0x1 ; ; 0x2c
3.42558445 ; IN ; 0x3 ; 0x1 ; ; 0x2c
3.4278718179999994 ; IN ; 0x3 ; 0x1 ; ; 0x4d
3.430162988 ; IN ; 0x3 ; 0x1 ; ; 0x2c
3.432453256 ; IN ; 0x3 ; 0x1 ; ; 0x30
3.434772662 ; IN ; 0x3 ; 0x1 ; ; 0x2e
3.437039062 ; IN ; 0x3 ; 0x1 ; ; 0x30
3.439396734 ; IN ; 0x3 ; 0x1 ; ; 0x2c
3.441620334 ; IN ; 0x3 ; 0x1 ; ; 0x4d
3.443961274 ; IN ; 0x3 ; 0x1 ; ; 0x2c
3.446205974 ; IN ; 0x3 ; 0x1 ; ; 0x2c
3.448496342 ; IN ; 0x3 ; 0x1 ; ; 0x30
3.450787278 ; IN ; 0x3 ; 0x1 ; ; 0x30
3.453149486 ; IN ; 0x3 ; 0x1 ; ; 0x30
3.45539722 ; IN ; 0x3 ; 0x1 ; ; 0x30
3.457663554 ; IN ; 0x3 ; 0x1 ; ; 0x2a
3.45996176 ; IN ; 0x3 ; 0x1 ; ; 0x35
3.46224186 ; IN ; 0x3 ; 0x1 ; ; 0x33
3.464585632 ; IN ; 0x3 ; 0x1 ; ; 0xd
3.4668302980000005 ; IN ; 0x3 ; 0x1 ; ; 0xa
3.469149972 ; IN ; 0x3 ; 0x1 ; ; 0x24
3.471411904 ; IN ; 0x3 ; 0x1 ; ; 0x47
3.473773844 ; IN ; 0x3 ; 0x1 ; ; 0x50
3.47599771 ; IN ; 0x3 ; 0x1 ; ; 0x47
3.478397916 ; IN ; 0x3 ; 0x1 ; ; 0x53
3.480586118 ; IN ; 0x3 ; 0x1 ; ; 0x41
3.482866284 ; IN ; 0x3 ; 0x1 ; ; 0x2c
3.485157556 ; IN ; 0x3 ; 0x1 ; ; 0x41
3.487455056 ; IN ; 0x3 ; 0x1 ; ; 0x2c
3.48977433 ; IN ; 0x3 ; 0x1 ; ; 0x31
3.49203363 ; IN ; 0x3 ; 0x1 ; ; 0x2c
3.494398402 ; IN ; 0x3 ; 0x1 ; ; 0x2c
3.496622068 ; IN ; 0x3 ; 0x1 ; ; 0x2c
3.498962942 ; IN ; 0x3 ; 0x1 ; ; 0x2c
3.501200708 ; IN ; 0x3 ; 0x1 ; ; 0x2c
3.50349091 ; IN ; 0x3 ; 0x1 ; ; 0x2c
3.50578908 ; IN ; 0x3 ; 0x1 ; ; 0x2c
3.508151154 ; IN ; 0x3 ; 0x1 ; ; 0x2c
3.510398886 ; IN ; 0x3 ; 0x1 ; ; 0x2c
3.51265802 ; IN ; 0x3 ; 0x1 ; ; 0x2c
3.514963426 ; IN ; 0x3 ; 0x1 ; ; 0x2c
3.51724356 ; IN ; 0x3 ; 0x1 ; ; 0x2c
3.5195873 ; IN ; 0x3 ; 0x1 ; ; 0x2c
3.521824866 ; IN ; 0x3 ; 0x1 ; ; 0x2c
3.524151638 ; IN ; 0x3 ; 0x1 ; ; 0x2c
3.526413638 ; IN ; 0x3 ; 0x1 ; ; 0x2a
3.528775512 ; IN ; 0x3 ; 0x1 ; ; 0x31
3.53099221 ; IN ; 0x3 ; 0x1 ; ; 0x45
3.533399584 ; IN ; 0x3 ; 0x1 ; ; 0xd
3.535587786 ; IN ; 0x3 ; 0x1 ; ; 0xa
3.537868018 ; IN ; 0x3 ; 0x1 ; ; 0x24
3.540159222 ; IN ; 0x3 ; 0x1 ; ; 0x47
3.542449558 ; IN ; 0x3 ; 0x1 ; ; 0x50
3.544775996 ; IN ; 0x3 ; 0x1 ; ; 0x52
3.547035364 ; IN ; 0x3 ; 0x1 ; ; 0x4d
3.54940017 ; IN ; 0x3 ; 0x1 ; ; 0x43
3.551616636 ; IN ; 0x3 ; 0x1 ; ; 0x2c
3.553964608 ; IN ; 0x3 ; 0x1 ; ; 0x32
3.556202274 ; IN ; 0x3 ; 0x1 ; ; 0x32
3.55849251 ; IN ; 0x3 ; 0x1 ; ; 0x34
3.56078358 ; IN ; 0x3 ; 0x1 ; ; 0x39
3.56315282 ; IN ; 0x3 ; 0x1 ; ; 0x34
3.565400656 ; IN ; 0x3 ; 0x1 ; ; 0x30
3.567659522 ; IN ; 0x3 ; 0x1 ; ; 0x2e
3.569965094 ; IN ; 0x3 ; 0x1 ; ; 0x39
3.572245228 ; IN ; 0x3 ; 0x1 ; ; 0x31
3.574588968 ; IN ; 0x3 ; 0x1 ; ; 0x34
3.576826532 ; IN ; 0x3 ; 0x1 ; ; 0x2c
3.579153306 ; IN ; 0x3 ; 0x1 ; ; 0x56
3.581408138 ; IN ; 0x3 ; 0x1 ; ; 0x2c
3.58377718 ; IN ; 0x3 ; 0x1 ; ; 0x2c
3.585993878 ; IN ; 0x3 ; 0x1 ; ; 0x2c
3.588401252 ; IN ; 0x3 ; 0x1 ; ; 0x2c
3.590589452 ; IN ; 0x3 ; 0x1 ; ; 0x2c
3.59286962 ; IN ; 0x3 ; 0x1 ; ; 0x2c
3.59516089 ; IN ; 0x3 ; 0x1 ; ; 0x2c
3.597451224 ; IN ; 0x3 ; 0x1 ; ; 0x33
3.599777664 ; IN ; 0x3 ; 0x1 ; ; 0x30
3.602037098 ; IN ; 0x3 ; 0x1 ; ; 0x31
3.604401736 ; IN ; 0x3 ; 0x1 ; ; 0x30
3.606618236 ; IN ; 0x3 ; 0x1 ; ; 0x32
3.608966276 ; IN ; 0x3 ; 0x1 ; ; 0x33
3.6112038760000003 ; IN ; 0x3 ; 0x1 ; ; 0x2c
3.613494244 ; IN ; 0x3 ; 0x1 ; ; 0x2c
3.615785282 ; IN ; 0x3 ; 0x1 ; ; 0x2c
3.618154488 ; IN ; 0x3 ; 0x1 ; ; 0x4e
3.620402222 ; IN ; 0x3 ; 0x1 ; ; 0x2a
3.622661356 ; IN ; 0x3 ; 0x1 ; ; 0x34
3.624966762 ; IN ; 0x3 ; 0x1 ; ; 0x42
3.627239828 ; IN ; 0x3 ; 0x1 ; ; 0xd
3.629590634 ; IN ; 0x3 ; 0x1 ; ; 0xa
3.6318213 ; IN ; 0x3 ; 0x1 ; ; 0x24
3.634154974 ; IN ; 0x3 ; 0x1 ; ; 0x50
3.636402706 ; IN ; 0x3 ; 0x1 ; ; 0x53
3.638778846 ; IN ; 0x3 ; 0x1 ; ; 0x52
3.640988478 ; IN ; 0x3 ; 0x1 ; ; 0x46
3.643403018 ; IN ; 0x3 ; 0x1 ; ; 0x31
3.64559112 ; IN ; 0x3 ; 0x1 ; ; 0x35
3.647864254 ; IN ; 0x3 ; 0x1 ; ; 0x36
3.650155458 ; IN ; 0x3 ; 0x1 ; ; 0x2c
3.652445758 ; IN ; 0x3 ; 0x1 ; ; 0x32
3.654779332 ; IN ; 0x3 ; 0x1 ; ; 0x33
3.657024398 ; IN ; 0x3 ; 0x1 ; ; 0x2c
3.659403404 ; IN ; 0x3 ; 0x1 ; ; 0x31
3.661612836 ; IN ; 0x3 ; 0x1 ; ; 0x2c
3.663967944 ; IN ; 0x3 ; 0x1 ; ; 0x30
3.6661913420000003 ; IN ; 0x3 ; 0x1 ; ; 0x2a
3.668488878 ; IN ; 0x3 ; 0x1 ; ; 0x30
3.670779816 ; IN ; 0x3 ; 0x1 ; ; 0x39
3.673067518 ; IN ; 0x3 ; 0x1 ; ; 0xd
3.675403888 ; IN ; 0x3 ; 0x1 ; ; 0xa
4.36261286 ; IN ; 0x3 ; 0x1 ; ; 0x24
4.3649892 ; IN ; 0x3 ; 0x1 ; ; 0x47
4.367198498 ; IN ; 0x3 ; 0x1 ; ; 0x50
4.3694888 ; IN ; 0x3 ; 0x1 ; ; 0x47
4.371801074 ; IN ; 0x3 ; 0x1 ; ; 0x47
4.37407454 ; IN ; 0x3 ; 0x1 ; ; 0x41
4.376425146 ; IN ; 0x3 ; 0x1 ; ; 0x2c
4.378655878 ; IN ; 0x3 ; 0x1 ; ; 0x32
4.380989684 ; IN ; 0x3 ; 0x1 ; ; 0x32
4.383241518 ; IN ; 0x3 ; 0x1 ; ; 0x34
4.385524686 ; IN ; 0x3 ; 0x1 ; ; 0x39
4.387822856 ; IN ; 0x3 ; 0x1 ; ; 0x34
4.390177896 ; IN ; 0x3 ; 0x1 ; ; 0x31
4.39242563 ; IN ; 0x3 ; 0x1 ; ; 0x2e
4.394691932 ; IN ; 0x3 ; 0x1 ; ; 0x39
4.3969901700000005 ; IN ; 0x3 ; 0x1 ; ; 0x31
4.399277570000001 ; IN ; 0x3 ; 0x1 ; ; 0x35
And here is my output on the GIGA board. I think my reformatting of the setup messages may be off from the format used in this library.
Will look more later.
0.8235413139999996 ; SETUP ; 0x0 ; 0x0 ; [GET_DESCRIPTOR - DEVICE #:0 I:0x0 L:0x8] ; 0x80 0x6 0x0 0x1 0x0 0x0 0x8 0x0
0.823572564 ; IN ; 0x0 ; 0x0 ; ; 0x12 0x1 0x10 0x1 0x0 0x0 0x0 0x40
0.8236289000000001 ; SETUP ; 0x0 ; 0x0 ; SET_ADDRESS I:0x0 L:0x0] ; 0x0 0x5 0x1 0x0 0x0 0x0 0x0 0x0
0.8251230399999995 ; SETUP ; 0x0 ; 0x1 ; [GET_DESCRIPTOR - DEVICE #:0 I:0x0 L:0x8] ; 0x80 0x6 0x0 0x1 0x0 0x0 0x8 0x0
0.8251527999999998 ; IN ; 0x0 ; 0x1 ; ; 0x12 0x1 0x10 0x1 0x0 0x0 0x0 0x40
1.264212954 ; SETUP ; 0x0 ; 0x1 ; [GET_DESCRIPTOR - DEVICE #:0 I:0x0 L:0x12] ; 0x80 0x6 0x0 0x1 0x0 0x0 0x12 0x0
1.2642497819999998 ; IN ; 0x0 ; 0x1 ; SET_PROTOCOL(0x0xb) ; 0x12 0x1 0x10 0x1 0x0 0x0 0x0 0x40 0x7b 0x6 0x3 0x23 0x0 0x4 0x1 0x2 0x0 0x1
1.2891692259999996 ; SETUP ; 0x0 ; 0x1 ; [GET_DESCRIPTOR - CONFIG #:0 I:0x0 L:0x9] ; 0x80 0x6 0x0 0x2 0x0 0x0 0x9 0x0
1.2892036539999998 ; IN ; 0x0 ; 0x1 ; 0x32(0x0x2) ; 0x9 0x2 0x27 0x0 0x1 0x1 0x0 0x80 0x32
1.2964246959999997 ; SETUP ; 0x0 ; 0x1 ; [GET_DESCRIPTOR - CONFIG #:0 I:0x0 L:0x27] ; 0x80 0x6 0x0 0x2 0x0 0x0 0x27 0x0
1.2964608019999997 ; IN ; 0x0 ; 0x1 ; 0x32(0x0x2) ; 0x9 0x2 0x27 0x0 0x1 0x1 0x0 0x80 0x32 0x9 0x4 0x0 0x0 0x3 0xff 0x0 0x0 0x0 0x7 0x5 0x81 0x3 0xa 0x0 0x1 0x7 0x5 0x2 0x2 0x40 0x0 0x0 0x7 0x5 0x83 0x2 0x40 0x0 0x0
1.450657988 ; SETUP ; 0x0 ; 0x1 ; [SET_CONFIGURATION I:0x0 L:0x0] ; 0x0 0x9 0x1 0x0 0x0 0x0 0x0 0x0
1.6530577039999999 ; SETUP ; 0x0 ; 0x1 ; [RT:0xc0 R:0x1 I:0x0 L:0x1] ; 0xc0 0x1 0x84 0x84 0x0 0x0 0x1 0x0
1.65309938 ; IN ; 0x0 ; 0x1 ; ; 0x2
1.6549540139999999 ; SETUP ; 0x0 ; 0x1 ; [RT:0x40 R:0x1 I:0x0 L:0x0] ; 0x40 0x1 0x4 0x4 0x0 0x0 0x0 0x0
1.6565016919999997 ; SETUP ; 0x0 ; 0x1 ; [RT:0xc0 R:0x1 I:0x0 L:0x1] ; 0xc0 0x1 0x84 0x84 0x0 0x0 0x1 0x0
1.6565657979999997 ; IN ; 0x0 ; 0x1 ; ; 0x2
1.6583490379999999 ; SETUP ; 0x0 ; 0x1 ; [RT:0xc0 R:0x1 I:0x0 L:0x1] ; 0xc0 0x1 0x83 0x83 0x0 0x0 0x1 0x0
1.658419658 ; IN ; 0x0 ; 0x1 ; ; 0xff
1.659981534 ; SETUP ; 0x0 ; 0x1 ; [RT:0xc0 R:0x1 I:0x0 L:0x1] ; 0xc0 0x1 0x84 0x84 0x0 0x0 0x1 0x0
1.66005065 ; IN ; 0x0 ; 0x1 ; ; 0x2
1.6619761599999998 ; SETUP ; 0x0 ; 0x1 ; [RT:0x40 R:0x1 I:0x1 L:0x0] ; 0x40 0x1 0x4 0x4 0x1 0x0 0x0 0x0
1.6634887079999998 ; SETUP ; 0x0 ; 0x1 ; [RT:0xc0 R:0x1 I:0x0 L:0x1] ; 0xc0 0x1 0x84 0x84 0x0 0x0 0x1 0x0
1.663545138 ; IN ; 0x0 ; 0x1 ; ; 0x2
1.665349984 ; SETUP ; 0x0 ; 0x1 ; [RT:0xc0 R:0x1 I:0x0 L:0x1] ; 0xc0 0x1 0x83 0x83 0x0 0x0 0x1 0x0
1.6654065919999999 ; IN ; 0x0 ; 0x1 ; ; 0xff
1.6670463180000001 ; SETUP ; 0x0 ; 0x1 ; [RT:0x40 R:0x1 I:0x1 L:0x0] ; 0x40 0x1 0x0 0x0 0x1 0x0 0x0 0x0
1.6686649319999998 ; SETUP ; 0x0 ; 0x1 ; [RT:0x40 R:0x1 I:0x0 L:0x0] ; 0x40 0x1 0x1 0x0 0x0 0x0 0x0 0x0
1.6703448339999996 ; SETUP ; 0x0 ; 0x1 ; [RT:0x40 R:0x1 I:0x24 L:0x0] ; 0x40 0x1 0x2 0x0 0x24 0x0 0x0 0x0
1.6719630319999996 ; SETUP ; 0x0 ; 0x1 ; [RT:0x40 R:0x1 I:0x0 L:0x0] ; 0x40 0x1 0x8 0x0 0x0 0x0 0x0 0x0
1.6735900199999996 ; SETUP ; 0x0 ; 0x1 ; [RT:0x40 R:0x1 I:0x0 L:0x0] ; 0x40 0x1 0x9 0x0 0x0 0x0 0x0 0x0
1.67550986 ; SETUP ; 0x0 ; 0x1 ; I:0x0 L:0x7] ; 0xa1 0x21 0x0 0x0 0x0 0x0 0x7 0x0
1.6755662879999995 ; IN ; 0x0 ; 0x1 ; ; 0x80 0x25 0x0 0x0 0x0 0x0 0x0
1.6801512859999999 ; SETUP ; 0x0 ; 0x1 ; I:0x0 L:0x7] ; 0x21 0x14 0x0 0x0 0x0 0x0 0x7 0x0
1.680287222 ; OUT ; 0x0 ; 0x1 ; ; 0xc0 0x12 0x0 0x0 0x0 0x0 0x8
2.6814822140000008 ; SETUP ; 0x0 ; 0x1 ; [RT:0x40 R:0x1 I:0x0 L:0x0] ; 0x40 0x1 0x0 0x0 0x0 0x0 0x0 0x0
2.6834819120000004 ; SETUP ; 0x0 ; 0x1 ; I:0x0 L:0x7] ; 0xa1 0x21 0x0 0x0 0x0 0x0 0x7 0x0
2.6835469919999997 ; IN ; 0x0 ; 0x1 ; ; 0x80 0x25 0x0 0x0 0x0 0x0 0x0
2.6859502739999996 ; SETUP ; 0x0 ; 0x1 ; I:0x0 L:0x0] ; 0x21 0x22 0x3 0x0 0x0 0x0 0x0 0x0
Found the issue, in the message used to set the Baud/format, my editing had 20 instead of 0x20
USBHost_FTDI_plus-231030a.zip (5.8 KB)
I am not doing anything with the data yet...
SBHostFTDI::rxHandler() called240012EC - 24 : $
USBHostFTDI::rxHandler() called240012EC - 47 50 : GP
USBHostFTDI::rxHandler() called240012EC - 52 : R
USBHostFTDI::rxHandler() called240012EC - 4D : M
USBHostFTDI::rxHandler() called240012EC - 43 2C : C,
USBHostFTDI::rxHandler() called240012EC - 32 : 2
USBHostFTDI::rxHandler() called240012EC - 33 : 3
USBHostFTDI::rxHandler() called240012EC - 34 37 : 47
USBHostFTDI::rxHandler() called240012EC - 30 : 0
USBHostFTDI::rxHandler() called240012EC - 30 : 0
USBHostFTDI::rxHandler() called240012EC - 2E 30 : .0
USBHostFTDI::rxHandler() called240012EC - 30 : 0
USBHostFTDI::rxHandler() called240012EC - 30 : 0
USBHostFTDI::rxHandler() called240012EC - 2C : ,
USBHostFTDI::rxHandler() called240012EC - 41 2C : A,
USBHostFTDI::rxHandler() called240012EC - 34 : 4
USBHostFTDI::rxHandler() called240012EC - 38 : 8
USBHostFTDI::rxHandler() called240012EC - 32 35 : 25
USBHostFTDI::rxHandler() called240012EC - 2E : .
USBHostFTDI::rxHandler() called240012EC - 36 : 6
USBHostFTDI::rxHandler() called240012EC - 35 34 : 54
USBHostFTDI::rxHandler() called240012EC - 32 : 2
USBHostFTDI::rxHandler() called240012EC - 2C : ,
USBHostFTDI::rxHandler() called240012EC - 4E : N
USBHostFTDI::rxHandler() called240012EC - 2C 31 : ,1
USBHostFTDI::rxHandler() called240012EC - 32 : 2
USBHostFTDI::rxHandler() called240012EC - 32 : 2
USBHostFTDI::rxHandler() called240012EC - 33 37 : 37
USBHostFTDI::rxHandler() called240012EC - 2E : .
USBHostFTDI::rxHandler() called240012EC - 33 : 3
USBHostFTDI::rxHandler() called240012EC - 35 31 : 51
USBHostFTDI::rxHandler() called240012EC - 30 : 0
USBHostFTDI::rxHandler() called240012EC - 2C : ,
USBHostFTDI::rxHandler() called240012EC - 57 : W
USBHostFTDI::rxHandler() called240012EC - 2C 30 : ,0
USBHostFTDI::rxHandler() called240012EC - 2E : .
USBHostFTDI::rxHandler() called240012EC - 30 : 0
USBHostFTDI::rxHandler() called240012EC - 30 2C : 0,
USBHostFTDI::rxHandler() called240012EC - 31 : 1
USBHostFTDI::rxHandler() called240012EC - 2E 33 : .3
USBHostFTDI::rxHandler() called240012EC - 31 : 1
USBHostFTDI::rxHandler() called240012EC - 2C : ,
USBHostFTDI::rxHandler() called240012EC - 33 30 : 30
USBHostFTDI::rxHandler() called240012EC - 31 : 1
USBHostFTDI::rxHandler() called240012EC - 30 : 0
USBHostFTDI::rxHandler() called240012EC - 32 33 : 23
USBHostFTDI::rxHandler() called240012EC - 2C : ,
USBHostFTDI::rxHandler() called240012EC - 2C 2C : ,,
USBHostFTDI::rxHandler() called240012EC - 41 : A
USBHostFTDI::rxHandler() called240012EC - 2A 37 : *7
USBHostFTDI::rxHandler() called240012EC - 32 : 2
USBHostFTDI::rxHandler() called240012EC - 0D : .
USBHostFTDI::rxHandler() called240012EC - 0A
Next add it to a Serial RX queue. Not sure if I will use the one part of the ArduinoHost-API code, which is not safe... Or the hacked up version I did for UNO R4..
I also forgot how stupid these devices are... You talk at baud of 4800 and they send only 1 or 2 characters per USB packet... But at least they are talking
Quick update, I hacked in the rxBuffer code and @Merlin513 earlier code for GPS and...
So that part is working...
Now to add in txBuffer support, and then try with other adapters.
Did a bunch of debugging on the gamepad sketch and found the problem. Real simple actually. With a PS4 attached I am now getting the data streaming and was actually able to set rumble and lights. Alot more to make the sketch generic. But now seeing data:
lx: 84, ly: 7D, rx: 85, ry: 80
lx: 84, ly: 7D, rx: 85, ry: 80
lx: 84, ly: 7D, rx: 85, ry: 80
lx: 84, ly: 7D, rx: 85, ry: 80
lx: 84, ly: 7D, rx: 85, ry: 80
lx: 84, ly: 7D, rx: 85, ry: 80
lx: 84, ly: 7D, rx: 85, ry: 80
lx: 84, ly: 7D, rx: 85, ry: 80
lx: 84, ly: 7D, rx: 85, ry: 80
lx: 84, ly: 7D, rx: 85, ry: 80
lx: 84, ly: 7D, rx: 85, ry: 80
lx/ly - left joystick, rx/ry - right joystick. Next up is to get buttons, setrumble and leds.
heres is the sketch if you want to see:
GamePad-231031a.zip (3.9 KB)
Great stuff! will have to play after I get a little farther along with Serial.
As I implied earlier playing with trying to TX to them. Currently it is not using buffer. Need to first setup a time out timer to flush the queue if no new stuff added within latency period...
So far PL2303 - Input from it is working.
Output is not... I need to double check my startup stuff, to see if maybe DTR/RTS or the like not right.
CP2104 appears to be working (Using Adafruit adapter)
FTDI: stuck as main library code it not handling the Get Device Desriptor correctly for these boards (8 byte Control endpoint)
CH340G (Sparkfun adapter): Also stuck same issue as FTDI.
Maybe I will add CDC ACM stuff in here for the fun of it.
Started playing, but so far not getting very far. I have tried plugging in a few boards that support CDC ACM,, but so far they are failing, in reading the configuration descriptor: I tried with Teensy 3.2, Teensy MicroMod, UNO R4 MINIMA.
Here is some of the debug output:
VID: 16C0, PID: 483 Unknown
[USB_TRANSFER: c:\Users\kurte\Documents\Arduino\libraries\Arduino_USBHostMbed5\src\USBHost\USBHost.cpp:1202]----- CONTROL READ [dev: 0x2400c914 - hub: 0 - port: 1] ------
[USB_TRANSFER: c:\Users\kurte\Documents\Arduino\libraries\Arduino_USBHostMbed5\src\USBHost\USBHost.cpp:1216]Control transfer on device: 1
[USB_TRANSFER: c:\Users\kurte\Documents\Arduino\libraries\Arduino_USBHostMbed5\src\USBHost\USBHost.cpp:1220]SETUP PACKET:
80 6 0 2 0 0 9 0
[USB_TRANSFER: c:\Users\kurte\Documents\Arduino\libraries\Arduino_USBHostMbed5\src\USBHost\USBHost.cpp:1248]CONTROL setup stage USB_TYPE_IDLE
[USB_TRANSFER: c:\Users\kurte\Documents\Arduino\libraries\Arduino_USBHostMbed5\src\USBHost\USBHost.cpp:1277]CONTROL READ stage USB_TYPE_IDLE
[USB_TRANSFER: c:\Users\kurte\Documents\Arduino\libraries\Arduino_USBHostMbed5\src\USBHost\USBHost.cpp:1285]CONTROL READ SUCCESS [9 bytes transferred]
09 02 43 00 02 01 00 C0 32
[USB_TRANSFER: c:\Users\kurte\Documents\Arduino\libraries\Arduino_USBHostMbed5\src\USBHost\USBHost.cpp:1318]CONTROL ack stage USB_TYPE_IDLE
[USB_DBG: c:\Users\kurte\Documents\Arduino\libraries\Arduino_USBHostMbed5\src\USBHost\USBHost.cpp:877]TOTAL_LENGTH: 67 NUM_INTERF: 2
[USB_TRANSFER: c:\Users\kurte\Documents\Arduino\libraries\Arduino_USBHostMbed5\src\USBHost\USBHost.cpp:1202]----- CONTROL READ [dev: 0x2400c914 - hub: 0 - port: 1] ------
[USB_TRANSFER: c:\Users\kurte\Documents\Arduino\libraries\Arduino_USBHostMbed5\src\USBHost\USBHost.cpp:1216]Control transfer on device: 1
[USB_TRANSFER: c:\Users\kurte\Documents\Arduino\libraries\Arduino_USBHostMbed5\src\USBHost\USBHost.cpp:1220]SETUP PACKET:
80 6 0 2 0 0 43 0
[USB_TRANSFER: c:\Users\kurte\Documents\Arduino\libraries\Arduino_USBHostMbed5\src\USBHost\USBHost.cpp:1248]CONTROL setup stage USB_TYPE_IDLE
[USB_TRANSFER: c:\Users\kurte\Documents\Arduino\libraries\Arduino_USBHostMbed5\src\USBHost\USBHost.cpp:1277]CONTROL READ stage USB_TYPE_ERROR
[USB_TRANSFER: c:\Users\kurte\Documents\Arduino\libraries\Arduino_USBHostMbed5\src\USBHost\USBHost.cpp:1285]CONTROL READ SUCCESS [0 bytes transferred]
[USB_ERR: c:\Users\kurte\Documents\Arduino\libraries\Arduino_USBHostMbed5\src\USBHost\USBHost.cpp:885]controlRead FAILED(18)
[USB_INFO: c:\Users\kurte\Documents\Arduino\libraries\GIGA_USBHostMBed5_devices\src\USBHostSerialDevice.cpp:86]Enumerate returned status: 18
[USB_DBG: c:\Users\kurte\Documents\Arduino\libraries\GIGA_USBHostMBed5_devices\src\USBHostSerialDevice.cpp:82] Dev: (nil)
[USB_DBG: c:\Users\kurte\Documents\Arduino\libraries\GIGA_USBHostMBed5_devices\src\USBHostSerialDevice.cpp:82] Dev: (nil)
[USB_DBG: c:\Users\kurte\Documents\Arduino\libraries\GIGA_USBHostMBed5_devices\src\USBHostSerialDevice.cpp:82] Dev: (nil)
[USB_DBG: c:\Users\kurte\Documents\Arduino\libraries\GIGA_USBHostMBed5_devices\src\USBHostSerialDevice.cpp:82] Dev: (nil)
No USB host Serial device connected
LA output, imported into excel:
1.267202212 | SETUP | 0x0 | 0x0 | [GET_DESCRIPTOR - DEVICE #:0 I:0x0 L:0x8] | 0x80 0x6 0x0 0x1 0x0 0x0 0x8 0x0 |
---|---|---|---|---|---|
1.267601186 | IN | 0x0 | 0x0 | 0x12 0x1 0x0 0x2 0x0 0x0 0x0 0x40 | |
1.270084156 | SETUP | 0x0 | 0x0 | SET_ADDRESS I:0x0 L:0x0] | 0x0 0x5 0x1 0x0 0x0 0x0 0x0 0x0 |
1.273809328 | SETUP | 0x0 | 0x1 | [GET_DESCRIPTOR - DEVICE #:0 I:0x0 L:0x8] | 0x80 0x6 0x0 0x1 0x0 0x0 0x8 0x0 |
1.274206898 | IN | 0x0 | 0x1 | 0x12 0x1 0x0 0x2 0x0 0x0 0x0 0x40 | |
1.918727608 | SETUP | 0x0 | 0x1 | [GET_DESCRIPTOR - DEVICE #:0 I:0x0 L:0x12] | 0x80 0x6 0x0 0x1 0x0 0x0 0x12 0x0 |
1.92624921 | IN | 0x0 | 0x1 | GET_REPORT(0x0x1) | 0x12 0x1 0x0 0x2 0x0 0x0 0x0 0x40 0x41 0x23 0x69 0x0 0x0 0x1 0x1 0x2 0x3 0x1 |
2.00154863 | SETUP | 0x0 | 0x1 | [GET_DESCRIPTOR - CONFIG #:0 I:0x0 L:0x9] | 0x80 0x6 0x0 0x2 0x0 0x0 0x9 0x0 |
2.009047378 | IN | 0x0 | 0x1 | 0xFA(0x0xa) | 0x9 0x2 0x5d 0x0 0x3 0x1 0x0 0xc0 0xfa |
2.064736672 | SETUP | 0x0 | 0x1 | [GET_DESCRIPTOR - CONFIG #:0 I:0x0 L:0x5d] | 0x80 0x6 0x0 0x2 0x0 0x0 0x5d 0x0 |
2.072251272 | IN | 0x0 | 0x1 | 0xFA(0x0xa) | 0x9 0x2 0x5d 0x0 0x3 0x1 0x0 0xc0 0xfa 0x8 0xb 0x0 0x2 0x2 0x2 0x0 0x0 0x9 0x4 0x0 0x0 0x1 0x2 0x2 0x0 0x4 0x5 0x24 0x0 0x20 0x1 0x5 0x24 0x1 0x0 0x1 0x4 0x24 0x2 0x2 0x5 0x24 0x6 0x0 0x1 0x7 0x5 0x81 0x3 0x8 0x0 0x10 0x9 0x4 0x1 0x0 0x2 0xa 0x0 0x0 0x0 0x7 0x5 0x2 |
2.07233818 | IN | 0x0 | 0x1 | GET_REPORT(0x0x0) | 0x2 0x40 0x0 0x0 0x7 0x5 0x82 0x2 0x40 0x0 0x0 0x9 0x4 0x2 0x0 0x0 0xfe 0x1 0x1 0x5 0x9 0x21 0xd 0xe8 0x3 0x0 0x10 0x1 0x1 |
8.200600526 | SETUP | 0x0 | 0x1 | [GET_DESCRIPTOR - DEVICE #:0 I:0x0 L:0x12] | 0x80 0x6 0x0 0x1 0x0 0x0 0x12 0x0 |
8.208157634 | IN | 0x0 | 0x1 | GET_REPORT(0x0x1) | 0x12 0x1 0x0 0x2 0x0 0x0 0x0 0x40 0x41 0x23 0x69 0x0 0x0 0x1 0x1 0x2 0x3 0x1 |
8.284104494 | SETUP | 0x0 | 0x1 | [GET_DESCRIPTOR - CONFIG #:0 I:0x0 L:0x9] | 0x80 0x6 0x0 0x2 0x0 0x0 0x9 0x0 |
8.291666942 | IN | 0x0 | 0x1 | 0xFA(0x0xa) | 0x9 0x2 0x5d 0x0 0x3 0x1 0x0 0xc0 0xfa |
8.34732098 | SETUP | 0x0 | 0x1 | [GET_DESCRIPTOR - CONFIG #:0 I:0x0 L:0x5d] | 0x80 0x6 0x0 0x2 0x0 0x0 0x5d 0x0 |
8.354854048 | IN | 0x0 | 0x1 | 0xFA(0x0xa) | 0x9 0x2 0x5d 0x0 0x3 0x1 0x0 0xc0 0xfa 0x8 0xb 0x0 0x2 0x2 0x2 0x0 0x0 0x9 0x4 0x0 0x0 0x1 0x2 0x2 0x0 0x4 0x5 0x24 0x0 0x20 0x1 0x5 0x24 0x1 0x0 0x1 0x4 0x24 0x2 0x2 0x5 0x24 0x6 0x0 0x1 0x7 0x5 0x81 0x3 0x8 0x0 0x10 0x9 0x4 0x1 0x0 0x2 0xa 0x0 0x0 0x0 0x7 0x5 0x2 |
8.354940826 | IN | 0x0 | 0x1 | GET_REPORT(0x0x0) | 0x2 0x40 0x0 0x0 0x7 0x5 0x82 0x2 0x40 0x0 0x0 0x9 0x4 0x2 0x0 0x0 0xfe 0x1 0x1 0x5 0x9 0x21 0xd 0xe8 0x3 0x0 0x10 0x1 0x1 |
Like some of the failures in previous post,it appears like it required two transfers (Control endpoint transfer size 64)
Still debugging
Been spending the last few days playing with my gamepad sketch.
For a Genuine PS4 and a Voyee clone was able to connect no problem and retrieve data. Also did several additional functions to make it look more like the joystick code we used on the Teensy. This includes rumble and setting the leds.
So using the available method:
gamepad buttons = 81
lx: 128, ly: 125, rx: 126, ry: 126
ltv: 0, rtv: 255
gamepad buttons = 81
lx: 128, ly: 125, rx: 126, ry: 126
ltv: 0, rtv: 255
gamepad buttons = 81
lx: 128, ly: 125, rx: 126, ry: 126
ltv: 0, rtv: 255
Eventually will add in accel/gyro/joystick angles.
Unfortunately the other 2 PS4 Clones both behave slightly differently.
For the Teiros controller it connects but no data is returned:
VID: 0x54C, PID: 0x5C4
Match PID/VID:
GamepadController:: gamepadType_=2
(parseInterface) NB: 0, Class: 0x3, Subclass: 0x0, Protocol: 0x0
After get end points
New Gamepad device: VID:054c PID:05c4 [dev: 0x2400c8f4 - intf: 0]Dev connected
Joystick connected
With the teiros looking that the debug data it does try to read it but keeps giving me CONTROL READ SUCCESS [0 bytes transferred]
For the other PS4 clone controller it will not connect:
VID: 0x54C, PID: 0x9CC
Match PID/VID:
GamepadController:: gamepadType_=2
No gamepad connected
Did try an Xbox controller and same think will not connect so can not go further with that device.
I am also getting more of the Serial stuff working.
@BobTheDog - I believe your code that changes the USB request code, such that a USB transfer can span multiple packets is working better for me now. Not sure why it was not working for me when I first tried it, but after doing some more debugging, stuff is starting to work
This includes FTDI adapters, whose control endpoint has transfer size of 8, which implies that the device descriptor spans 3 packets.
However it still has problems reading the one from the UNO R4 Minima.
As I mentioned earlier today in another thread, I have the serial object able to retrieve the devices, manufacturer id, product ID, manufacturer name, product name and Serial number. The last three only if the device actually has strings defined.
So for example, I plugged in the FTDI USB adapter, and Jumper'd between RX and TX pins.
My WIP branch is up at:
KurtE/Arduino_USBHostMbed5 at WIP (github.com)
My Serial object code with examples is up at:
Starting USB host Serial device test...
VID: 403, PID: 6001 FTDI
USBHostSerialDevice::parseInterface nb:0, cl:255 isub:255 iprot:255
USBHostSerialDevice::useEndpoint(0, 2, 2)
USBHostSerialDevice::useEndpoint(0, 2, 1)
connect hser_device_found
After get end points
New hser device: VID:0403 PID:6001 [dev: 0x2400c91c - intf: 0]
>>>>>>>>>>>>>> connected returning true <<<<<<<<<<<<<<<<<<<<
USB host Serial device(403:6001) connected trying begin
Manufacturer: FTDI
Product: FT232R USB UART
Serial Number: A400BXLN
*** Serial does not support availableForWrite ***
bulkwrite(0x240012c4, 5)
240012C4 - 61 62 63 64 0A : abcd.
0x2400c3a4 0x240012c4 5
bulkwrite(0x240012c4, 12)
240012C4 - 69 66 20 61 74 20 66 69 72 73 74 0A : if at fi rst.
0x2400c3a4 0x240012c4 12
if at first
It still has debug code and the like printing.
Mostly playing!
Like @KurtE am trying to get more wired gamepads working with usbhost.
Just got the Nintendo Switch Pro working with the gamepad library. Still have some bugs to work out with correct axis indices but does have signs of life. Also in the process of adding in @KurtE;s methods to retrieve manufacturer name, product ID and product name.
But its getting late here so more tomorrow.
I am now using @KurtE's U[SBHost libarary](https://KurtE/Arduino_USBHostMbed5 at WIP (github.com)) which incorporates changes recommend by @BobTheDog and code to get the manuf/ser/product strings.
While I have the a couple PS4's working and the Switch pro controller I can't seem to get the Teiros PS4 controller to connect nor the XBOX.
The Teiros keeps giving me an error message:
Starting gamepad test...
No gamepad connected
[USB_DBG: d:\Users\Merli\Documents\Arduino\libraries\Arduino_USBHostMbed5-WIP\src\USBHost\USBDeviceConnected.cpp:91]init dev: 0x2400c944
[USB_DBG: d:\Users\Merli\Documents\Arduino\libraries\Arduino_USBHostMbed5-WIP\src\USBHost\USBHost.cpp:612]USBEndpoint created (0x2400c29c): type: 0, dir: 1, size: 8, addr: 0, state: USB_TYPE_IDLE
[USB_DBG: d:\Users\Merli\Documents\Arduino\libraries\Arduino_USBHostMbed5-WIP\src\USBHost\USBHost.cpp:647]USBHost::addEndpoint(0x0 0 0x2400c29c) 0x2400c260
[USB_DBG: d:\Users\Merli\Documents\Arduino\libraries\Arduino_USBHostMbed5-WIP\src\USBHost\USBHost.cpp:625]Resetting hub 0, port 1
[USB_DBG: d:\Users\Merli\Documents\Arduino\libraries\Arduino_USBHostMbed5-WIP\src\USBHost\USBHost.cpp:150]usb_thread read device descriptor on dev: 0x2400c944
[USB_ERR: d:\Users\Merli\Documents\Arduino\libraries\Arduino_USBHostMbed5-WIP\src\USBHost\USBHost.cpp:154]usb_thread could not read dev descr
[USB_DBG: d:\Users\Merli\Documents\Arduino\libraries\Arduino_USBHostMbed5-WIP\src\USBHost\USBHost.cpp:625]Resetting hub 0, port 1
[USB_DBG: d:\Users\Merli\Documents\Arduino\libraries\Arduino_USBHostMbed5-WIP\src\USBHost\USBHost.cpp:150]usb_thread read device descriptor on dev: 0x2400c944
**[USB_ERR: d:\Users\Merli\Documents\Arduino\libraries\Arduino_USBHostMbed5-WIP\src\USBHost\USBHost.cpp:154]usb_thread could not read dev descr**
[USB_DBG: d:\Users\Merli\Documents\Arduino\libraries\Arduino_USBHostMbed5-WIP\src\USBHost\USBHost.cpp:625]Resetting hub 0, port 1
[USB_DBG: d:\Users\Merli\Documents\Arduino\libraries\Arduino_USBHostMbed5-WIP\src\USBHost\USBHost.cpp:150]usb_thread read device descriptor on dev: 0x2400c944
No gamepad connected
While the XBOXOne controller:
9495969793929899
joystick_right_trigger_value = rtv;
gamepad.setRumble(ltv, rtv);
}
break;
default:
break;
}
Serial.println();
}
delay(200);
Not connected. Select a board and a port to connect automatically.
New Line
115200 baud
Starting gamepad test...
[USB_DBG: d:\Users\Merli\Documents\Arduino\libraries\Arduino_USBHostMbed5-WIP\src\USBHost\USBHost.cpp:939]Enumerate dev: 0x2400c944 index: 0
[USB_DBG: d:\Users\Merli\Documents\Arduino\libraries\Arduino_USBHostMbed5-WIP\src\USBHost\USBHost.cpp:945]dev: 0x2400c944 nb_intf: 0
[USB_DBG: d:\Users\Merli\Documents\Arduino\libraries\Arduino_USBHostMbed5-WIP\src\USBHost\USBHost.cpp:946]dev: 0x2400c944 nb_intf_attached: 0
[USB_DBG: d:\Users\Merli\Documents\Arduino\libraries\Arduino_USBHostMbed5-WIP\src\USBHost\USBHost.cpp:952]Enumerate dev: 0x2400c944
[USB_DBG: d:\Users\Merli\Documents\Arduino\libraries\Arduino_USBHostMbed5-WIP\src\USBHost\USBHost.cpp:963]DEVICE DESCRIPTOR(18):
12 01 00 02 FF 47 D0 40 5E 04 EA 02 01 03 01 02 03 01
[USB_DBG: d:\Users\Merli\Documents\Arduino\libraries\Arduino_USBHostMbed5-WIP\src\USBHost\USBHost.cpp:975]CLASS: FF VID: 045E PID: 02EA
[USB_INFO: D:\Users\Merli\Documents\Arduino\Arduino Giga\USBHostGamepad\USBHostGamepad.cpp:262]VID: 45E, PID: 2EA
Match PID/VID:
[USB_INFO: D:\Users\Merli\Documents\Arduino\Arduino Giga\USBHostGamepad\USBHostGamepad.cpp:266]GamepadController:: gamepadType_=3
[USB_DBG: d:\Users\Merli\Documents\Arduino\libraries\Arduino_USBHostMbed5-WIP\src\USBHost\USBHost.cpp:879]TOTAL_LENGTH: 96 NUM_INTERF: 3
[USB_ERR: d:\Users\Merli\Documents\Arduino\libraries\Arduino_USBHostMbed5-WIP\src\USBHost\USBHost.cpp:887]controlRead FAILED(18)
No gamepad connected
Line 887 is in the getConfigurationDescriptor function of USBHost so basically same error.
Here is the sketch if you want to give it a try- also going to push the sketch to @KurtE's device library
USBHostGamepad-231105a.zip (15.7 KB)
Think there is something strange going on with USBHost - at least with my sketch. If I use the Teiros controller for example and I turn debug on:
//Debug is disabled by default
#define DEBUG 4 /*INFO,ERR,WARN*/
#define DEBUG_TRANSFER 1
#define DEBUG_EP_STATE 0
#define DEBUG_EVENT 0
and rerun the sketch it gets past that error and completes the read:
No gamepad connected
[USB_DBG: d:\Users\Merli\Documents\Arduino\libraries\Arduino_USBHostMbed5-WIP\src\USBHost\USBDeviceConnected.cpp:91]init dev: 0x2400c944
[USB_DBG: d:\Users\Merli\Documents\Arduino\libraries\Arduino_USBHostMbed5-WIP\src\USBHost\USBHost.cpp:612]USBEndpoint created (0x2400c29c): type: 0, dir: 1, size: 8, addr: 0, state: USB_TYPE_IDLE
[USB_DBG: d:\Users\Merli\Documents\Arduino\libraries\Arduino_USBHostMbed5-WIP\src\USBHost\USBHost.cpp:647]USBHost::addEndpoint(0x0 0 0x2400c29c) 0x2400c260
[USB_DBG: d:\Users\Merli\Documents\Arduino\libraries\Arduino_USBHostMbed5-WIP\src\USBHost\USBHost.cpp:625]Resetting hub 0, port 1
[USB_DBG: d:\Users\Merli\Documents\Arduino\libraries\Arduino_USBHostMbed5-WIP\src\USBHost\USBHost.cpp:150]usb_thread read device descriptor on dev: 0x2400c944
[USB_TRANSFER: d:\Users\Merli\Documents\Arduino\libraries\Arduino_USBHostMbed5-WIP\src\USBHost\USBHost.cpp:1204]----- CONTROL READ [dev: 0x2400c944 - hub: 0 - port: 1] ------
[USB_TRANSFER: d:\Users\Merli\Documents\Arduino\libraries\Arduino_USBHostMbed5-WIP\src\USBHost\USBHost.cpp:1218]Control transfer on device: 0
and it does complete connection to control but no data is pulled from the Controller:
[USB_TRANSFER: d:\Users\Merli\Documents\Arduino\libraries\Arduino_USBHostMbed5-WIP\src\USBHost\USBHost.cpp:1222]SETUP PACKET:
80 6 2 3 9 4 A2 0
[USB_TRANSFER: d:\Users\Merli\Documents\Arduino\libraries\Arduino_USBHostMbed5-WIP\src\targets\TARGET_STM\USBEndpoint_STM.cpp:201]HAL_HCD_HC_SubmitRequest(0x24001538, 0, 0, 0, 0, 0x2400cc4f, 8, 1)
[USB_TRANSFER: d:\Users\Merli\Documents\Arduino\libraries\Arduino_USBHostMbed5-WIP\src\USBHost\USBHost.cpp:1250]CONTROL setup stage USB_TYPE_IDLE
[USB_TRANSFER: d:\Users\Merli\Documents\Arduino\libraries\Arduino_USBHostMbed5-WIP\src\targets\TARGET_STM\USBEndpoint_STM.cpp:201]HAL_HCD_HC_SubmitRequest(0x24001538, 0, 1, 0, 1, 0x2400b980, 162, 1)
[USB_TRANSFER: d:\Users\Merli\Documents\Arduino\libraries\Arduino_USBHostMbed5-WIP\src\USBHost\USBHost.cpp:1279]CONTROL READ stage USB_TYPE_IDLE
[USB_TRANSFER: d:\Users\Merli\Documents\Arduino\libraries\Arduino_USBHostMbed5-WIP\src\USBHost\USBHost.cpp:1287]CONTROL READ SUCCESS [40 bytes transferred]
28 03 57 00 69 00 72 00 65 00 6C 00 65 00 73 00 73 00 20 00 63 00 6F 00 6E 00 74 00 72 00 6F 00 6C 00 6C 00 65 00 72 00
[USB_TRANSFER: d:\Users\Merli\Documents\Arduino\libraries\Arduino_USBHostMbed5-WIP\src\targets\TARGET_STM\USBEndpoint_STM.cpp:201]HAL_HCD_HC_SubmitRequest(0x24001538, 0, 0, 0, 1, 0x0, 0, 1)
[USB_TRANSFER: d:\Users\Merli\Documents\Arduino\libraries\Arduino_USBHostMbed5-WIP\src\USBHost\USBHost.cpp:1320]CONTROL ack stage USB_TYPE_IDLE
[Product: UWireless controllerS
B_TRANSFER: d:\Users\Merli\Documents\Arduino\libraries\Arduino_USBHostMbed5-WIP\src\targets\TARGET_STM\USBEndpoint_STM.cpp:201]HAL_HCD_HC_SubmitRequest(0x24001538, 1, 1, 3, 1, 0x24001314, 64, 1)
READ SUCCESS [0 bytes transferred - td: 0x240018AB] on ep: [0x2400c334 - addr: 83]:
[USB_TRANSFER: d:\Users\Merli\Documents\Arduino\libraries\Arduino_USBHostMbed5-WIP\src\USBHost\USBHost.cpp:1115]----- INTERRUPT READ [dev: 0x2400c944 - Gamepad - hub: 0 - port: 1 - addr: 1 - ep: 83]------
[USB_TRANSFER: d:\Users\Merli\Documents\Arduino\libraries\Arduino_USBHostMbed5-WIP\src\targets\TARGET_STM\USBEndpoint_STM.cpp:201]HAL_HCD_HC_SubmitRequest(0x24001538, 1, 1, 3, 1, 0x24001314, 64, 1)
READ SUCCESS [0 bytes transferred - td: 0x240018C7] on ep: [0x2400c334 - addr: 83]:
Notice the read success - 0 bytes transferred???
Here is the entire dump if anybody is up to the challenge:
Tycom-Terios-debug.txt (64.4 KB)
Sorry distracted today, trying to convert the USBHostSerial code to use
bulkWrite, that don't wait, but instead get callback. Also trying to use a timer to trigger a flush...
Mostly getting the crash blinks...
I am making some progress now... i.e. I think I have a version of the Serial Device code that I can enable the TX output to be buffered. And It outputs now without the crash red blinking sequence
However, some of the mechanism I am using here feels really convoluted! Wondering if there is a cleaner more obvious way. Not sure if some of this would warrant its own thread? I will describe the issues in parts.
Part 1: Timer - When a sketch does output to the device, and does not fill up the 64 byte packet, some form of timer is started. My first attempt was with the Portenta_H7_TimerInterrupt objects: I was able to get the timer to trigger. However, doing anything like tying to queue new USB packet, or printf... would cause the BLINKS..
Converted over to use an Timeout object
mbed::Timeout writeTO_;
Similar to the above doing simple things worked, calling to queue new packet BLINKS!
I am getting a warning about using:
writeTO_.attach_us(mbed::callback(this, &USBHostSerialDevice::processTXTimerCB), write_timeout_);
The message:
:\Users\kurte\Documents\Arduino\libraries\GIGA_USBHostMBed5_devices\src\USBHostSerialDevice.h:201:100: warning: 'void mbed::TickerBase::attach_us(mbed::Callback<void()>, us_timestamp_t)' is deprecated: Pass a chrono duration, not an integer microsecond count. For example use `10ms` rather than `10000`. [since mbed-os-6.0.0] [-Wdeprecated-declarations]
writeTO_.attach_us(mbed::callback(this, &USBHostSerialDevice::processTXTimerCB), write_timeout_);}
I have not looked yet on how to pass let's say 5ms... I tried that and compiler gave me an error....
During this I learned about using the mbed::Callback mechanism, as a way to avoid having to do my own wrapper functions, to map back to the right object.
Note: Some systems I worked on used the USB SOF (Start Of Frame) interrupt to drive similar timer.
Part 2: Queue USB Packet from Timer Event -
I started a thread
if (buffer_writes_) {
#if 1
if (writeTOThread_ == nullptr) {
writeTOThread_ = new rtos::Thread(osPriorityNormal2, 3 * 1024);
if (writeTOThread_) {
writeTOThread_->start(mbed::callback(this, &USBHostSerialDevice::tx_timeout_thread_proc));
}
}
Which waits for simple events (sort of like the USB_Process)
void USBHostSerialDevice::tx_timeout_thread_proc() {
while(1) {
osEvent evt = mail_serobj_event.get();
if (evt.status == osEventMail) {
USBHostSerialDevice::message_t * serobj_msg = (message_t*)evt.value.p;
switch (serobj_msg->event_id) {
case LATENCY_TIMEOUT_MSG:
{
if (!usb_tx_queued_ && !in_tx_write_) {
stopWriteTimeout(); // stop the timer.
submit_async_bulk_write(2); // submit the request for the rest of the data.
} else {
// maybe we need to reschedule
startWriteTimeout();
}
}
break;
}
mail_serobj_event.free(serobj_msg);
}
}
}
And now the Timer Call back function sets the event:
// Handle the timer interrupt
void USBHostSerialDevice::processTXTimerCB() {
USBHostSerialDevice::message_t * serobj_msg = mail_serobj_event.alloc();
serobj_msg->event_id = LATENCY_TIMEOUT_MSG;
mail_serobj_event.put(serobj_msg);
}
I am getting some compiler warnings on this, which I am cleaning up....
This sure feels round about! Am I missing some other more obvious way?
Ok my turn. Been tweaking the sketch and doing some clean ups. What is working:
- A couple of my DS4's
- XBox One S
- PS3 (yes its old but it works except for LEDs and left rumble - not sure why on that one.
Whats not working
- Teiros (DS4) and another of my DS4's
- Switch is now broken but more on this next
With the switch if I just and dbg turned for errors/warnings I will get
[USB_ERR: d:\Users\Merli\Documents\Arduino\libraries\Arduino_USBHostMbed5-WIP\src\USBHost\USBHost.cpp:154]usb_thread could not read dev descr
But if I also enable dbg transfers it works!!!!
No clue on this one. May update USB host to latest recommend changes in the PR to see if that helps.
As I mentioned in the thread:
MBED_CONF_PLATFORM _CALLBACK_NONTRIVIAL - inconsistent usage (RED BLINKS) - Hardware / GIGA R1 - Arduino Forum
The current sources of the library Arduino_USBHostMbed5, which I believe that were released today 0.3.1 fixes a lot of the Crashes. Including unplugging the device.
This as well as the changes proposed by @BobTheDog in the thread:
Appears to fix a lot of the problems with reading device descriptors, that span multiple USB packets likewise for the configuration descriptors, and maybe other things as well.
All of these changes are in my WIP branch of my fork of the library:
As mentioned in post #32
The Serial object appears to be working on several different devices including:
Arduino UNO R4 MINIMA, Teensy 3.x, Teensy 4.x (although only at Full Speed), FTDI, CP2104, CH321. The PL2303 code appears to have some issues... Will debug again soon.
The main example that copies stuff from USB to the USB Host and back was updated, to now detect when the device goes away and then detects if a new one is plugged in. Likewise it detects if the Serial object changes baud rate and then tries to restart the plugged in device at that baud rate.
Now back to play
Did a diversion from gamepads and hooked up a Logitech Extreme 3d Pro joystick: Amazon.com: Logitech G Extreme 3D Pro USB Joystick for Windows - Black/Silver : Electronics
and managed to get it working.
Starting gamepad test...
No gamepad connected
Match PID/VID:
After get end points
New Gamepad device: VID:046d PID:c215 [dev: 0x2400cb0c - intf: 0]Match PID/VID:
Joystick connected:
Manufacturer: Logitech
Product: Logitech Extreme 3D
rx: 8, ry: 114, rz: 127, hat: 8
Slider: 161, ButtonsA: 21, ButtonsB: 0
Button Map: 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0,
rx: 20, ry: 114, rz: 127, hat: 8
Slider: 161, ButtonsA: 21, ButtonsB: 0
Button Map: 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0,
rx: 252, ry: 81, rz: 127, hat: 8
Slider: 161, ButtonsA: 21, ButtonsB: 0
Button Map: 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0,
rx: 11, ry: 2, rz: 127, hat: 8
Slider: 163, ButtonsA: 21, ButtonsB: 0
Button Map: 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0,
rx: 0, ry: 2, rz: 127, hat: 8
Slider: 163, ButtonsA: 21, ButtonsB: 0
Button Map: 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0,
rx: 28, ry: 2, rz: 127, hat: 8
Slider: 163, ButtonsA: 21, ButtonsB: 0
Button Map: 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0,
rx: 100, ry: 242, rz: 127, hat: 8
Slider: 161, ButtonsA: 21, ButtonsB: 0
Button Map: 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0,
rx: 8, ry: 242, rz: 127, hat: 8
Slider: 163, ButtonsA: 21, ButtonsB: 0
Button Map: 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0,
rx: 0, ry: 242, rz: 131, hat: 8
Slider: 163, ButtonsA: 21, ButtonsB: 0
Button Map: 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0,
The joystick has 12 buttons in 2 groups (ButtonsA and ButtonsB) with a little coding broke it out so all 12 buttons can be tracked individually. Button Map shows a couple different buttons being pressed.