I have a Python script that writes data packets to an Arduino board via pySerial . Sometimes when writing code on the board, pySerial causes an I / O error with error 5.
Some studies indicate that this indicates an error while writing to a file representing the connection to the Arduino board.
The code that sends sends only single-byte packets:
try: # Check if it already a single byte if isinstance(byte, str): if len(byte) == 1: # It is. Send it. self.serial.write(byte) else: # It not raise PacketException # Check if it an integer elif isinstance(byte, int): self.serial.write(chr(byte)) # It is; convert it to a byte and send it else: raise PacketException # I don't know what this is. except Exception as ex: print("Exception is: " + ex.__getitem__() + " " + ex.__str__())
Error printed by this code:
Errno 5 OS I / O Error Error
Is there something wrong with my code when sending? Do I need to check if the serial connection is ready to send or something delay after sending? Or could there be a hardware problem or hardware connection?
Change I reviewed the Linux implementation from pyserial, and the implementation only passes the error to my code. So there are no new real ideas from there. Is there a good way to check what is happening in the program?
source share