Jetson Nano and Arduino serial connection

Hello, I’m trying to use the Jetson Nano to control a cart-pole model implemented in Arduino.

The idea is to use the Nano as an MPC controller and send the control action to the model (which is insed of the Arduino UNO), wait for the model to throw its output and take the data back to the Jetson to recalculate the control action and so on.

I’ve been able to connect the Arduino and the Jetson through serial port, but I don’t know how to make each one wait for the other’s data to come in.

I’m currently trying to write a simple communications example by using ‘pyserial’ library to send a number to the Arduino, which will multiply it by two and send it back to the Nano, which will show it, but I can’t achieve it.

Do you think you could post here how to do that simple program?

Thanks in advance.

Have a reference to this topic to check if can help.