Report
4 months ago.

Ubuntu and Serial Communication to Nucleo-L432KC

Hi,

I have a Nucleo-L432KC board that communicates to TeraTerm on Windows. The results is shown below:

/media/uploads/koosvanderwat/qqq.png

I initiate the serial communication as follows:

Serial pc(SERIAL_TX, SERIAL_RX); // pc communication

and then later I set the baud rate:

int main()
{
    pc.baud(9600);

When I attach the same board to a Ubuntu machine the communication fails. I have tried with two applications. I first tried with GNU screen:

I run GNU screen with the following command:

sudo screen /dev/ttyACM0 9600

But then I get the following result with lost and incorrect characters:

/media/uploads/koosvanderwat/terminal_screen_garbage.pngI theb

I then tried with putty. I use the following command:

sudo putty /dev/ttyACM0 -serial -sercfg 9600,8,n,1,N

Unfortunately the result was the same:

/media/uploads/koosvanderwat/putty_fail.jpeg

Can Anyone give advice to me?

Thanking you in advance.

Koos

Comment on this question

1 Answer

3 months, 4 weeks ago.

Hi, you not need set the baud rate to 9600, it is default. I do not have experience with linux and your terminal applications, I use Termite and Hercules on Windows only. But is ASCII or symbols as "/n" or "/r" same for Windows and Linux? Check settings of your applications about these characters.

You can check https://superuser.com/questions/374028/how-are-n-and-r-handled-differently-on-linux-and-windows

Maybe try simple program first and then check https://os.mbed.com/docs/v5.7/tutorials/serial-comm.html#using-terminal-applications-on-linux

Dear Jan,

Thank you for posting your answer. You were correct in assuming that the "/n" and the "/r" characters caused a problem. I am now using them in the following order "/r/n" and it seems to make a big difference.

Unfortunately the problem is not completely solved. I sometimes plug and unplug my board from the usb port during testing. What I see now is the following:

1. When I run the program for the first time everything works as expected. 2. When I unplug the USB port and re-plug the USB port to run the program again then the information received gets scrambled. 3. It seems that Linux does not close the virtual com port after the USB plug has been removed. When the board is re-plugged then the received bits are corrupted possibly by bits that was partly received when the board was unplugged. My next steps will be to research how to tell the operating system to clear the virtual com ports before I re-connect.

Kind regards

Koos

posted by Koos van der Wat 17 Aug 2018

Hi Koos,

I think it is not problem of the system. The port is opened by your terminal app and when you unplug USB, the port is still opened by your app, so you need re-open the port in your app. Check settings of your app, find another app with auto reconnect or make a new one.

J.

posted by Jan Kamidra 20 Aug 2018

To post an answer, please log in.