How to Echo Newline ("\x0A") Without Appended Carriage Return ("\x0D")

31 Views Asked by At

I am trying to transfer individual bytes from a binary file over UART from a Linux MPU to a separate MCU. The code I am using to transfer the data is shown below:

echo -ne $data > /dev/ttyS1

This code has been working great for me except for in one situation when the data includes a hex value of \x0A (newline character). Whenever I echo the \x0A value with the code above, it actually sends \x0D\x0A (carriage return and newline character). Because of this, I get errors in my binary file transfer.

I have tried sending the following commands:

echo -ne "\x0A" > /dev/ttyS1
echo -ne "\n" > /dev/ttyS1

When I do that, the UART bus is showing the 0x0D0A transfer as shown in the image below.

UART Transfer

Is there a way I can force the echo to just send the 0x0A character without the 0x0D character appended to it?

0

There are 0 best solutions below