Hello,
Why this function is limited to 9 char, is it a specification of HID protocol or something else.
Hello,
Why this function is limited to 9 char, is it a specification of HID protocol or something else.
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)).
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
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?
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.
void HID_::USBSend(const uint8_t* data, int len)
{
USB_Send(pluggedEndpoint | TRANSFER_RELEASE, data, len);
}
// 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:
HID().USBSend(data, 9);
It's working, but not that:
HID().USBSend(data, 10);
It's make no sense.
It doex make sense if the limit is imposed ar the receiving side; the link I gave mentions it.
But why when you connect your USB device to your PC, the bootloader can load 233 bytes for Descriptor ect ?
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?
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.
arduiko:
I am just sending random data, it's for testing.
How do you send data? Maybe show a simple example.
HID().USBSend(data, 9);