Open Kiliar opened 3 months ago
This will unfortunately not solve my problem, which is USB serial port disconnect. In this case, read will return 0, not an error. So this loop will run endlessly.
Oh.... so you have an issue when serial connection is up, but no data can be send or received using this lib? I had a similar issue and found a workaround by calling simple python script that will initialize serial port & send some data. It helps me most of the time, maybe it will help you to find proper solution.
import sys
import serial
import crc8
serial = serial.Serial()
serial.port = sys.argv[1]
serial.baudrate = int(sys.argv[2])
serial.open()
msg = bytearray.fromhex("0101")
hash = crc8.crc8()
hash.update(msg)
c = hash.digest()
serial.write(msg)
serial.write(c)
You can improve pulling logic on unix systems, by changing recursion to endless loop with some delay.