Rasperry pi uart and custom rs485 based protocol
<p>I'm trying to read data coming off of the primary uart /dev/ttyAMA0 on a raspberry pi which is sent from Arduino Nano.</p>

<p>Library on the arduino side <a href="https://gitlab.com/creator-makerspace/rs485-nodeproto" rel="nofollow">https://gitlab.com/creator-makerspace/rs485-nodeproto</a></p>

<p>So I use a simple python script to verify the data coming from the arduino:</p>

<pre><code>import serial

sp = serial.Serial(
    port="/dev/ttyAMA0",
    baudrate=9600,
    timeout=0.1
)

while True:
    i = sp.read()

    print i.encode("hex")
</code></pre>

<p>But the data coming out is corrupt / wrong about x times out of n times.</p>

<p>A good packet looks like
A0
2
1
4F
50
45
4E
B7
1B
80</p>

<p>Bad packets which is most of the time:
13
0a
7a
41
15
39
dd
1b
80
00</p>

<p>Also the test script works fine when using a USB to UART connected to the rs485 tranceiver instead of the internal uart.</p>

<p>Suggestions on what I am doing wrong?</p>