Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rawhid test device ProMicroRawHID Feature Report Problem #20

Closed
mcuee opened this issue May 31, 2023 · 8 comments
Closed

Rawhid test device ProMicroRawHID Feature Report Problem #20

mcuee opened this issue May 31, 2023 · 8 comments

Comments

@mcuee
Copy link

mcuee commented May 31, 2023

I have issues with the other example ProMicroRawHID in terms of Feature report.
https://github.com/todbot/hidapitester/tree/master/test_hardware/ProMicroRawHID

Reading input seems to be okay (I did the minor change to send 0x08 to 0x47. But the comments about 2s does not seem to be right. It seems to be once per second. Basically the code has been changed to 1s but the comment has not been updated.

Sending the output report seems to be okay as well since I can see the echo from Arduino terminal Window.

It does not seem to work when sending the feature report.

PS C:\work\hid\hidapitester> .\hidapitester --vidpid 2341:8037 --open --read-input-forever
Opening device, vid/pid: 0x2341/0x8037
Reading 64-byte input report 0, 250 msec timeout...read 64 bytes:
 08 09 0A 0B 0C 0D 0E 0F 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 20 21 22 23 24 25 26 27
 28 29 2A 2B 2C 2D 2E 2F 30 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E 3F 40 41 42 43 44 45 46 47
Reading 64-byte input report 0, 250 msec timeout...read 0 bytes:
Reading 64-byte input report 0, 250 msec timeout...read 0 bytes:
Reading 64-byte input report 0, 250 msec timeout...read 0 bytes:
Reading 64-byte input report 0, 250 msec timeout...read 64 bytes:
 08 09 0A 0B 0C 0D 0E 0F 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 20 21 22 23 24 25 26 27
 28 29 2A 2B 2C 2D 2E 2F 30 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E 3F 40 41 42 43 44 45 46 47
Reading 64-byte input report 0, 250 msec timeout...read 0 bytes:
Reading 64-byte input report 0, 250 msec timeout...read 0 bytes:
Reading 64-byte input report 0, 250 msec timeout...read 0 bytes:
Reading 64-byte input report 0, 250 msec timeout...read 64 bytes:
 08 09 0A 0B 0C 0D 0E 0F 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 20 21 22 23 24 25 26 27
 28 29 2A 2B 2C 2D 2E 2F 30 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E 3F 40 41 42 43 44 45 46 47
Reading 64-byte input report 0, 250 msec timeout...read 0 bytes:
Reading 64-byte input report 0, 250 msec timeout...read 0 bytes:
Reading 64-byte input report 0, 250 msec timeout...read 0 bytes:
Reading 64-byte input report 0, 250 msec timeout...read 64 bytes:
 08 09 0A 0B 0C 0D 0E 0F 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 20 21 22 23 24 25 26 27
 28 29 2A 2B 2C 2D 2E 2F 30 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E 3F 40 41 42 43 44 45 46 47
Reading 64-byte input report 0, 250 msec timeout...read 0 bytes:
Reading 64-byte input report 0, 250 msec timeout...

PS C:\work\hid\hidapitester> .\hidapitester --vidpid 2341:8037 --open --send-output 0x00,0x30,0x31
Opening device, vid/pid: 0x2341/0x8037
Writing output report of 64-bytes...wrote 65 bytes:
 00 30 31 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
Closing device

Arduino Serial Termainal echo
112115: sending packet
113116: sending packet
48
49
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
114117: sending packet
115118: sending packet
116119: sending packet
117120: sending packet

PS C:\work\hid\hidapitester> .\hidapitester --vidpid 2341:8037 --open --send-feature 0x00,0x30,0x31
Opening device, vid/pid: 0x2341/0x8037
Writing 64-byte feature report...wrote -1 bytes:
 00 30 31 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
Closing device
@mcuee
Copy link
Author

mcuee commented May 31, 2023

I do not have problems with TeensyRawHid.
https://github.com/todbot/hidapitester/tree/master/test_hardware/TeensyRawHid

TeensyRawHid run log.

  1. Input report is correct -- every 1s it will have one packet.
PS C:\work\hid\hidapitester> .\hidapitester --vidpid 16C0 --usagePage 0xFFAB --open --read-input-forever
Opening device, vid/pid:0x16C0/0x0000, usagePage/usage: FFAB/0
Device opened
Reading 64-byte input report 0, 250 msec timeout...read 0 bytes:
Reading 64-byte input report 0, 250 msec timeout...read 0 bytes:
Reading 64-byte input report 0, 250 msec timeout...read 0 bytes:
Reading 64-byte input report 0, 250 msec timeout...read 64 bytes:
 AB CD 00 D7 00 D6 00 D0 00 D0 00 E0 00 D5 00 B1 00 B0 00 AD 00 B5 00 99 00 A6 00 00 00 00 00 00
 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 D7
Reading 64-byte input report 0, 250 msec timeout...read 0 bytes:
Reading 64-byte input report 0, 250 msec timeout...read 0 bytes:
Reading 64-byte input report 0, 250 msec timeout...read 0 bytes:
Reading 64-byte input report 0, 250 msec timeout...read 64 bytes:
 AB CD 00 D7 00 D6 00 D0 00 D0 00 E0 00 D5 00 B0 00 AF 00 AD 00 B5 00 98 00 A6 00 00 00 00 00 00
 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 D8
Reading 64-byte input report 0, 250 msec timeout...read 0 bytes:
Reading 64-byte input report 0, 250 msec timeout...read 0 bytes:
Reading 64-byte input report 0, 250 msec timeout...read 0 bytes:
Reading 64-byte input report 0, 250 msec timeout...read 64 bytes:
 AB CD 00 D7 00 D6 00 D0 00 D0 00 E0 00 D5 00 B1 00 B0 00 AD 00 B5 00 98 00 A6 00 00 00 00 00 00
 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 D9
Reading 64-byte input report 0, 250 msec timeout...read 0 bytes:
Reading 64-byte input report 0, 250 msec timeout...read 0 bytes:
Reading 64-byte input report 0, 250 msec timeout...read 0 bytes:
Reading 64-byte input report 0, 250 msec timeout...read 64 bytes:
 AB CD 00 D7 00 D7 00 D1 00 D1 00 E0 00 D6 00 B1 00 B0 00 AD 00 B5 00 98 00 A5 00 00 00 00 00 00
 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 DA
Reading 64-byte input report 0, 250 msec timeout...read 0 bytes:
Reading 64-byte input report 0, 250 msec timeout...read 0 bytes:
Reading 64-byte input report 0, 250 msec timeout...read 0 bytes:
Reading 64-byte input report 0, 250 msec timeout...read 64 bytes:
 AB CD 00 D7 00 D7 00 D1 00 D0 00 E0 00 D6 00 B1 00 B0 00 AD 00 B5 00 98 00 A6 00 00 00 00 00 00
 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 DB
Reading 64-byte input report 0, 250 msec timeout...read 0 bytes:
Reading 64-byte input report 0, 250 msec timeout...read 0 bytes:
Reading 64-byte input report 0, 250 msec timeout...read 0 bytes:
Reading 64-byte input report 0, 250 msec timeout...read 64 bytes:
 AB CD 00 D8 00 D7 00 D1 00 D2 00 E1 00 D7 00 B1 00 B0 00 AE 00 B6 00 98 00 A6 00 00 00 00 00 00
 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 DC
Reading 64-byte input report 0, 250 msec timeout...read 0 bytes:
Reading 64-byte input report 0, 250 msec timeout...read 0 bytes:
Reading 64-byte input report 0, 250 msec timeout...read 0 bytes:
Reading 64-byte input report 0, 250 msec timeout...read 64 bytes:
 AB CD 00 D8 00 D8 00 D2 00 D2 00 E1 00 D6 00 B2 00 B1 00 AE 00 B6 00 99 00 A6 00 00 00 00 00 00
 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 DD
Reading 64-byte input report 0, 250 msec timeout...
  1. Output report is also correct.
PS C:\work\hid\hidapitester> .\hidapitester --vidpid 16C0 --usagePage 0xFFAB --open --send-output 0x00,0x21,0x22
Opening device, vid/pid:0x16C0/0x0000, usagePage/usage: FFAB/0
Device opened
Writing output report of 64-bytes...wrote 65 bytes:
 00 21 22 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
Closing device

And I can see the Arduini serial monitor received the packet.

...
Transmit packet 147
Received packet:
21 22 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
Transmit packet 148
Transmit packet 149
...

Another test:

PS C:\work\hid\hidapitester> .\hidapitester --vidpid 16C0 --usagePage 0xFFAB --open --send-output 0x21,0x22,0x23
Opening device, vid/pid:0x16C0/0x0000, usagePage/usage: FFAB/0
Device opened
Writing output report of 64-bytes...wrote 65 bytes:
 21 22 23 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
Closing device

And I can see the Arduini serial monitor received the packet.

Received packet:
21 22 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

@mcuee mcuee changed the title Rawhid test device Rawhid test device ProMicroRawHID Feature Report Problem May 31, 2023
@mcuee
Copy link
Author

mcuee commented Jun 1, 2023

I checked the HID report descriptor and it does not support Feature report at all.

Device Found
  type: 2341 8037
  path: \\?\HID#VID_2341&PID_8037&MI_02#7&20cef2ab&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number: C
  Manufacturer: Arduino LLC
  Product:      Arduino Micro
  Release:      100
  Interface:    2
  Usage (page): 0xc00 (0xffc0)
  Bus type: 1 (USB)

  Report Descriptor: (35 bytes)
0x06, 0xc0, 0xff, 0x0a, 0x00, 0x0c, 0xa1, 0x01, 0x09, 0x01,
0x15, 0x00, 0x26, 0xff, 0x00, 0x75, 0x08, 0x95, 0x40, 0x81,
0x02, 0x09, 0x02, 0x15, 0x00, 0x26, 0xff, 0x00, 0x75, 0x08,
0x95, 0x40, 0x91, 0x02, 0xc0,

HID Report Parser output
https://eleccelerator.com/usbdescreqparser/

0x06, 0xC0, 0xFF,  // Usage Page (Vendor Defined 0xFFC0)
0x0A, 0x00, 0x0C,  // Usage (0x0C00)
0xA1, 0x01,        // Collection (Application)
0x09, 0x01,        //   Usage (0x01)
0x15, 0x00,        //   Logical Minimum (0)
0x26, 0xFF, 0x00,  //   Logical Maximum (255)
0x75, 0x08,        //   Report Size (8)
0x95, 0x40,        //   Report Count (64)
0x81, 0x02,        //   Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position)
0x09, 0x02,        //   Usage (0x02)
0x15, 0x00,        //   Logical Minimum (0)
0x26, 0xFF, 0x00,  //   Logical Maximum (255)
0x75, 0x08,        //   Report Size (8)
0x95, 0x40,        //   Report Count (64)
0x91, 0x02,        //   Output (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile)
0xC0,              // End Collection

// 35 bytes

@mcuee
Copy link
Author

mcuee commented Jun 1, 2023

It seems to me by default feature report is not supported by the library.
https://github.com/NicoHood/HID/blob/master/src/SingleReport/RawHID.cpp

@mcuee
Copy link
Author

mcuee commented Jun 1, 2023

Issue resolved by fixing the above file.

static const uint8_t  _hidReportDescriptorRawHID[] PROGMEM = {
	/*    RAW HID */
    0x06, lowByte(RAWHID_USAGE_PAGE), highByte(RAWHID_USAGE_PAGE),      /* 30 */
    0x0A, lowByte(RAWHID_USAGE), highByte(RAWHID_USAGE),

    0xA1, 0x01,                  /* Collection 0x01 */
    // RawHID is not multireport compatible.
    // On Linux it might work with some modifications,
    // however you are not happy to use it like that.
    //0x85, HID_REPORTID_RAWHID,			 /* REPORT_ID */
    0x75, 0x08,                  /* report size = 8 bits */
    0x15, 0x00,                  /* logical minimum = 0 */
    0x26, 0xFF, 0x00,            /* logical maximum = 255 */

    0x95, RAWHID_TX_SIZE,        /* report count TX */
    0x09, 0x01,                  /* usage */
    0x81, 0x02,                  /* Input (array) */

    0x95, RAWHID_RX_SIZE,        /* report count RX */
    0x09, 0x02,                  /* usage */
    0x91, 0x02,                  /* Output (array) */
	
	0x95, RAWHID_RX_SIZE,        /* report count RX */
    0x09, 0x02,                  /* usage */
    0xB1, 0x02,                  /* Feature (array) */
    0xC0                         /* end collection */ 
};

@mcuee
Copy link
Author

mcuee commented Jun 1, 2023

Now it works.

PS C:\work\libusb\hidapitester> .\hidapitester.exe  --vidpid 2341:8037 --open --send-feature 0,0x11,0x22,0x33,0x44,0x55
Opening device, vid/pid: 0x2341/0x8037
Writing 64-byte feature report...wrote 64 bytes:
 00 11 22 33 44 55 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
Closing device

Arduino serial monitor:

received Feature report
first byte: 17 34 51 68 85 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 

@mcuee
Copy link
Author

mcuee commented Jun 2, 2023

I will close this issue here as it is not a problem with hidapitester but the HID library.

@mcuee
Copy link
Author

mcuee commented Jun 2, 2023

For Feature report, hidapitester needs to add first 0 in order to work with HID device without Feature report ID (tested under Windows). The zero will not appear on the wire and the device will not receive the firs zero.

PS C:\work\hid\hidapitester> .\hidapitester.exe --vidpid 2341:8037 --open --open -l 65 --send-feature 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64
Opening device, vid/pid: 0x2341/0x8037
Opening device, vid/pid: 0x2341/0x8037
Writing 65-byte feature report...wrote 65 bytes:
 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F
 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F 30 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E 3F
 40
Closing device

Arduino serial monitor output.

received Feature report
first byte: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 

@mcuee
Copy link
Author

mcuee commented Jun 2, 2023

BTW, I have also tested the other two tinyusb based example using an Arduino M0 clone and they both work as expected.

Test results here:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant