pySerial - missed messages - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: pySerial - missed messages (/thread-36181.html) |
pySerial - missed messages - q_nerk - Jan-25-2022 ESP32 is sending data via USB do desktop with Ubuntu 20.04 (at the end script will be used on RPI4). Yesterday it was working, today not. def read(): port = '/dev/ttyUSB0' baudrate = 115200 ser = serial.Serial(port, baudrate) data = ser.readline() text = data.decode(errors="ignore") return textWhat serial monitor from arduino ide see: What is terminal output from script: The funniest thing is that it was working yesterday, today is not. What I'm doing wrong? I tried to set different timeout, as well as None, and many other parameters with no result.
RE: pySerial - missed messages - deanhystad - Jan-25-2022 I don't know what happens when you repeat this over and over on an already opened serial port. ser = serial.Serial(port, baudrate)Does this close the already open connection? If so, that would flush anything remaining in the read buffer. I would open the port once and read many times. RE: pySerial - missed messages - Jeff_t - Jan-27-2022 Can you post the section of serial output code of the ESP32 so that we can see what your python script should expect and if there is a better way to read it. |