I have a program on my Arduino Due that receives lists of data, parsed by one of this solutions https://forum.arduino.cc/t/serial-input-basics-updated/382007 and it is working fine!
I am sending this data from my Raspberry Pi via UART. In the first column of the list is the topic, that the Arduino knows, what the datas are for. So I send a list and the first column is the topic, the rest (undefined length) are integers. Here is my mini example:
import serial
ser = serial.Serial(
port='/dev/ttyS0',
baudrate = 9600,
timeout=1
)
new_list = [b"topic"]
for i in range(10):
new_list.append(i)
def sendData(data):
ser.write(data)
sendData(new_list)
But now I get the Error "TypeError: 'bytes' object cannot be interpreted as an integer" and I don't know how to fix it. I've tried already many ways of encoding but then I just get others errors.
In the time from when it worked until now I've replaced the memory of my Raspberry Pi with new Raspbian OS, maybe a package is missing?
Full error traceback:
Traceback (most recent call last):
File "/media/local/2E32-36C4/test.py", line 17, in <module>
sendData(new_list)
File "/media/local/2E32-36C4/test.py", line 15, in sendData
ser.write(data)
File "/usr/lib/python3/dist-packages/serial/serialposix.py", line 598, in write
d = to_bytes(data)
File "/usr/lib/python3/dist-packages/serial/serialutil.py", line 68, in to_bytes
return bytes(bytearray(seq))
TypeError: 'bytes' object cannot be interpreted as an integer