Go Down

Topic: Why HID.SendReport() is limited at 9 char (Read 357 times) previous topic - next topic

arduiko

Feb 23, 2018, 03:16 pm Last Edit: Feb 23, 2018, 03:22 pm by arduiko
Hello,

Why this function is limited to 9 char, is it a specification of HID protocol or something else.

sterretje

#1
Feb 25, 2018, 04:53 am Last Edit: Feb 25, 2018, 05:03 am by sterretje
How do you know it's limited to 9 characters (it's actually bytes ;) ) The function itself does not impose the limit (as far as I can see, also not if you dig deeper (into USB_Send etc)).
Code: [Select]
int HID_::SendReport(uint8_t id, const void* data, int len)
{
auto ret = USB_Send(pluggedEndpoint, &id, 1);
if (ret < 0) return ret;
auto ret2 = USB_Send(pluggedEndpoint | TRANSFER_RELEASE, data, len);
if (ret2 < 0) return ret2;
return ret + ret2;
}


I suspect that it's actually 'imposed' by the function that calls SendReport. As you're talking about characters, I guess that you're using the keyboard library that has the struct
Code: [Select]
typedef struct
{
  uint8_t modifiers;
  uint8_t reserved;
  uint8_t keys[6];
} KeyReport;

which is 8 bytes in total.

The answer might be in HID Keyboard Without 6 Key Limit?
If you understand an example, use it.
If you don't understand an example, don't use it.

Electronics engineer by trade, software engineer by profession. Trying to get back into electronics after 15 years absence.

arduiko

Sorry I mean char by its length, not by its definition.
And no, it's not SendReport() nor USB_Send() because I redesigned them to delete all useless code that can interfere with its first purpose.

Code: [Select]

void HID_::USBSend(const uint8_t* data, int len)
{
USB_Send(pluggedEndpoint | TRANSFER_RELEASE, data, len);
}


Code: [Select]

// Blocking Send of data to an endpoint
int USB_Send(u8 ep, u8* data, int len)
{
    int len_ = len;

if (_usbSuspendState & (1<<SUSPI))
    {
//send a remote wakeup
UDCON |= (1 << RMWKUP);
}

    LockEP lock(ep);

    while (len--)
        Send8(*data++);

    ReleaseTX();

TXLED1; // light the TX LED
TxLEDPulse = TX_RX_LED_PULSE_MS;
   
return len_;
}


And if you try that:
Code: [Select]

HID().USBSend(data, 9);


It's working, but not that:
Code: [Select]

HID().USBSend(data, 10);


It's make no sense.

sterretje

It doex make sense if the limit is imposed ar the receiving side; the link I  gave mentions it.
If you understand an example, use it.
If you don't understand an example, don't use it.

Electronics engineer by trade, software engineer by profession. Trying to get back into electronics after 15 years absence.

arduiko

#4
Feb 25, 2018, 01:51 pm Last Edit: Feb 25, 2018, 02:00 pm by arduiko
But why when you connect your USB device to your PC, the bootloader can load 233 bytes for Descriptor ect ?
https://imgur.com/a/gqgoF

sterretje

Because it's a different part of the usb spec ? I really don't know, you're far more advanced in this than I am.

So what do you do in your code to send the data? Keyboard? Mouse? Something else?
If you understand an example, use it.
If you don't understand an example, don't use it.

Electronics engineer by trade, software engineer by profession. Trying to get back into electronics after 15 years absence.

arduiko

It's maybe the HID descriptor but like I don't know how to write it, I am blocked.

I am just sending random data, it's for testing.

sterretje

I am just sending random data, it's for testing.
How do you send data? Maybe show a simple example.
If you understand an example, use it.
If you don't understand an example, don't use it.

Electronics engineer by trade, software engineer by profession. Trying to get back into electronics after 15 years absence.

arduiko


Go Up