Arm Mbed OS support forum

MBED OS USBSerial bug?

Hi,
I am having trouble echoing back binary data that I am sending over to my STM32F429.
I am using USBSerial receive() and to receive the data
serial.receive(buf, MAX_BUFFER_SIZE, &size);
size is correct when received.
However, when echoing back the data using either
serial.putc(buf[x]);
serial.send(buf, size);
There is always one data messed up with the /x08o (see data send/receive below)
There is ONLY happens If my message chunk is bigger than 50 Bytes. At 50 Bytes It works flawlessly.

This is the log from the device

data recv: b’\x00\x00\x03 U\x03\x02\x08]\x03\x02\x08\xf9\x02\x02\x08\xfd\x02\x02\x08\x01\x03\x02\x08\x05\x03\x02\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x005\x02\x02\x08i\x03\x02\x08\x00\x00\x00\x00\xcd\x02\x02\x08\xdd\x02\x02\x08o\x03\x02\x08o\x03\x02\x08o\x03\x02\x08o\x03\x02\x08o\x03\x02\x08o\x03\x02\x08o\x03\x02\x08o\x03\x02\x08o\x03\x02\x08’

data send: b’\x00\x00\x03 U\x03\x02\x08]\x03\x02\x08\xf9\x02\x02\x08\xfd\x02\x02\x08\x01\x03\x02\x08\x05\x03\x02\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x005\x02\x02\x08i\x03\x02\x08\x00\x00\x00\x00\xcd\x02\x02\x08\xdd\x02\x02\x08\x03\x02\x08o\x03\x02\x08o\x03\x02\x08o\x03\x02\x08o\x03\x02\x08o\x03\x02\x08o\x03\x02\x08o\x03\x02\x08o\x03\x02\x08’

Anyone know why this is a thing ?

I don’t think there’s enough info in your post to know what’s going on (not that I’m going to be able to answer the question anyway).

From what you’ve provided I can’t say it is a bug, but I can’t say it’s s not either. To begin to help I’d have to spend time to work out what you are saying is wrong, and then looking into if it’s a bug or not is even more work.

To make it easier for someone to help you, I’d suggest you consider the following:

How you are sending the data?
How are you rendering the data and outputting it? (is it over the USB Serial, over a separate link, what code is actually outputting these characters?)
which \x08o is the messed up one and how is it messed up? (i.e. what did you expect, what did you get? Is it changed data, extra data or deleted data?)
If you change the data you send do you get a different issue or is it only the quantity of bytes? (I’d suggest using an easily identifiable sequence of bytes to allow working out what transformation is going on, and you work it out and say what it could be instead of asking others to do that)

I’ve just posted a not dissimilar piece of code for BufferedSerial and UnbufferedSerial. It’s not USBSerial, but it is remarkably similar in terms of the test code that isn’t behaving from the sound of it… Can’t say I’ve had many people investigating with me.

As it’s so similar, you may want to take a look:
UART losing data

Good luck.