Skip to content
Advertisement

Serial data over UART gets corrupted

I’m developing an application for a development board (Beagle Bone Black) that will send some data over UART peripheral. The developing board runs Linux Kernel (some Debian distribution, 3.8.x Linux Kernel version).

For sending and receiving data over UART I use the standard UNIX API: open(), read(), and write() family functions.

For setting the communication parameters (baud rate, stop/start bits, parity, etc…) I use the termios structure (from termios.h).

This is some relevant code sequence where I make the I/O settings:

JavaScript

There I opened two file descriptors:

  • fd_debug: Linked to a file, for debugging purposes.
  • fd_write: Linked to the UART peripheral (/dev/ttyO4 in my particular case).

This is the function that is executed when I want to send one byte over UART:

JavaScript

For checking if the data I send is received correctly over UART, I have connected the TX and RX pins (loopback test) on my board (because I want to be able to receive back the data that I send), and run minicom on that particular UART port:

JavaScript

After sending some data, I compared the two files (debugging file and the output file generated by minicom (which should contain the data received over UART)). The problem is that the data is not the same!

This is the actually data sent (in hexadecimal):

JavaScript

This is the data received in the debug file (it’s the same, so this confirms that there’s some UART problem):

JavaScript

And this is the data received by minicom tool (that was set to listen to the same UART port, and the same settings (baud, parity, etc):

JavaScript

As can be observed from a point all data gets corrupted, and there’s more bytes received.

For checking the actual data from the output files I used hexdump like this:

JavaScript

What could be the problem?

Advertisement

Answer

This seems to be Minicom responding to the ENQ character (0x05) and recording its response in the session capture. The additional data is Minicom2.6.1 which is not corruption. It is substituted for every 0x05 in your stream.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement