Cat corrupts serial port data

catserial porttty

I have an application which writes some bytes to a serial port. When I do cat /dev/ttyS0 to see what is being transferred, I find that the data is corrupted by the cat command. Is there any other way to see what is being sent on the serial port?

Does anyone know why cat changes the data?

Edit: There is another application on the other side and I want to intercept the data in order to check its content but the application must continue to work.

Best Answer

It's not corrupted. What's happening is that the cat command is getting some of the bytes, and your application is getting some of them. So when you run cat, any bytes read by it are missed by the app, and both cat and the app will see (different) partial streams that appear corrupted.

Related Question