Hello all,
I have a rather strange situation. I have in the past made a bunch of WORKING Python programs that reads serial data and trends it on a matplotlib graph in Python.
The data is formatted as a comma separated string, as in: "data,data,data,..."
Arduino example:
Serial.print(data1);
Serial.print(",");
Serial.print(data2);
Serial.print(",");
Serial.print(data3);
Serial.print(",");
...
Serial.println(datan);
From the python side I would read, decode and strip the incoming string with:
self.serialString = self.arduino.readline().strip().decode("UTF-8")
This used to work in the past, but for some strange reason, it doesn't work any more.
Now, I have tried on several machines that used to run the code, but none work.
That kind of rules out a Python or Pyserial version issue, as I tried on machines that would run it in the past.
The console gives me this error:
Arduion is type: <class 'serial.serialposix.Serial'>
Serial<id=0x7fb48cba9eb8, open=True>(port='/dev/ttyUSB0', baudrate=115200, bytesize=8, parity='N', stopbits=1, timeout=1, xonxoff=False, rtscts=False, dsrdtr=False)
opening serial port
Traceback (most recent call last):
File "mainMplGraph.py", line 312, in updateFigure
self.incomingData = self.arduino.readline().decode("UTF-8").strip()
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xfa in position 1: invalid start byte
opening serial port
Traceback (most recent call last):
File "mainMplGraph.py", line 312, in updateFigure
self.incomingData = self.arduino.readline().decode("UTF-8").strip()
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xfa in position 1: invalid start byte
I tried using the line self.serialString = self.arduino.readline().decode("UTF-8").strip()
too as suggested on stackexchange, but it does not work either.
Has something changed in the way the arduino Serial library formats data in recent times?
Does anyone have a suggesting as to what can be the issue? Should I post more of the code?
Thanks