Fixed report out length

This commit is contained in:
NicoHood 2015-09-22 21:07:04 +02:00
parent 803ecfddf5
commit f42b37ca8e

View file

@ -167,24 +167,28 @@ bool HID_::HID_Setup(USBSetup& setup, u8 i)
if(current->reportID == ID)
{
// Get the data length information and the corresponding bytes
// Assuming the host will never send more than 255 bytes
uint8_t length = setup.wLength;
void* data = malloc(length);
if(data){
uint8_t recvLength = length;
//TODO loop can be improved maybe? Or does the compiler do this already?
while(recvLength > USB_EP_SIZE){
USB_RecvControl(data + (length - recvLength), USB_EP_SIZE);
recvLength -= USB_EP_SIZE;
uint16_t length = (setup.wValueH << 8) | setup.wLength;
// Ensure that there IS some data TODO needed?
if(length)
{
void* data = malloc(length);
if(data){
uint16_t recvLength = length;
//TODO loop can be improved maybe? Or does the compiler do this already?
while(recvLength > USB_EP_SIZE){
USB_RecvControl(data + (length - recvLength), USB_EP_SIZE);
recvLength -= USB_EP_SIZE;
}
USB_RecvControl(data + (length - recvLength), recvLength);
// Data may contain the report ID again (Keyboard), maybe not (RawHID)
current->setReportData(data, length);
}
USB_RecvControl(data + (length - recvLength), recvLength);
// Data may contain the report ID again (Keyboard), maybe not (RawHID)
current->setReportData(data, length);
// Release data if the pointer still exists
free(data);
}
// Release data if the pointer still exists
free(data);
// Dont search any further
break;