As far as I can tell, that assignment to buffer->state shouldn't be there. usb_generic_control_rx_setup() will set the state itself if the retrieval completes, and sometimes it doesn't. If it doesn't, hidUSBDataSetup() will be called again. However, if the assignment above is present, then the buffer will be marked as unread twice (and so picked up by the application twice).
It seems that just removing the assignment fixes things.
In usb_hid.c:hidUSBDataSetup(), there's this code:
[code] usb_generic_control_rx_setup(buffer->buffer, buffer->bufferSize, &(buffer->state)); buffer->state = HID_BUFFER_UNREAD; [/code]
As far as I can tell, that assignment to
buffer->state
shouldn't be there.usb_generic_control_rx_setup()
will set the state itself if the retrieval completes, and sometimes it doesn't. If it doesn't,hidUSBDataSetup()
will be called again. However, if the assignment above is present, then the buffer will be marked as unread twice (and so picked up by the application twice).It seems that just removing the assignment fixes things.