Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
8 years, 9 months ago.
Wrong size USB packets?
Hi,
I've got code that sends two packets to an interrupt OUT endpoint on my K64F. The first is 8 bytes long, the second is 12.
I read them on the board in a loop using USBDevice::readEP_NB(). The weird thing is, if I send the packets immediately one after the other, I receive them both, but the second packet is truncated to 8 bytes. If there is a delay between the packets it works fine. The data in the packets appears to be correct, just truncated.
Does anyone know why this is? I thought maybe USB packets aren't buffered at all, so you can only have one queued for reading at a time. But if that is the case, how come the data for each packet is different? And how come I actually receive both packets?
Also if there is no buffer, is there a way to get an interrupt when a packet is received? Otherwise I don't see how you can implement a USB protocol and do something else at the same time...