1
votes

My issue is to make a serial communication between raspberry pi and another hardware. The recommended connection for this hardware is as shown on the manual, I have to connect, RX, TX, GND, RS, and CS.

But on raspberry pi we have only RX, TX so I connected RX and TX and The GNG of Pi to this hardware. I modified Pi's parameters as shown on the link : here

Then I maked a simple python program that initialize the communication, and send data. Here is the code : import serial,os port=serial.Serial("/dev/ttyAMA0",baudrate=9600) print ('port is ok') port.write('Command') rcv=port.read(10) print rcv

after running this code on pi, I got ('port is ok'), But the problem is that this hardware don't respond correctly to the command, and as respoce it gave me normally OK, but I got some extra caracter( non readable). Is that a problem of encoding? Can some one help about this?

2

2 Answers

1
votes

You need to check the baud rate on the other hardware or make sure that the length of the received message = to the printed message.

1
votes

In a serial communication, there are two important things to be careful :

  • The two devices have to work with the same baudrate IF the link is bidirectional.
  • When writing data on serial, you have to flush data just after the write(). refer to here for it. In a lot of case, flush isn't needed, but when two different devices have to communicate, it could unlock the comm'.

If it's not efficient, try to set up your other device with the same conf (no flow control, etc)