USBHost_t36 last character of packet is undetected until next packet sent.

Status
Not open for further replies.

pmurphy

Member
Let us say that my USB slave sends "Hello World\r\n"

My USB Host receiver:

while (USB.available() > 0) {
uint8_t auchBuf[512];
int cBytes(USB.readBytes(reinterpret_cast<char*>(auchBuf), constrain(USB.available(), 0, int(sizeof auchBuf))));
/* Note: cBytes/USB.available() reports strlen("Hello World\r\n") -1!! */

Serial.write(auchBuf, cBytes); //prints "Hello World\r" Note missing \n
}

Subsequent call to USB.available() report no new data.

Slave sends another "Hello World\r\n";
readBytes reads "\nHello World\r" // Note missing \n has now been received but final \n is once again missing from received packet.

Subsequent calls to USB.available() report no new data.
Until next packet is sent, at which time the missing \n is returned as the first octet in the packet and the final \n goes undetected.

It appears that the last octet received is stuck in the receive buffer, but undetected, or more likely an off by one error.
I tried issuing a read() after the readbytes(), but the read() timed out.

I tried this with a USB slave device, and a teensy 2++ as the slave device; The results were the same for both.

Patrick
 
You may have found a bug in the library. But if you want me or anyone to investigate and fix it, you really do need to gives us complete programs to run on both Teensy 3.6 or 4.0 or 4.1 (can't tell which you're using on the host side) and also the code to run on the Teensy++ 2.0. Even if the code is "trivial", you need to show 2 complete programs anyone can copy into Arduino and upload to the 2 boards... without any guesswork to fill in the rest of the code!
 
Status
Not open for further replies.
Back
Top