Mar-15-2024, 09:25 AM
Hello. I am running the following via the Raspberry PI :
Since the device reboots after connecting to the serialport, during the bootup, it prints out a bunch of garbage that I want to filter out. So I decided to sleep for 2 seconds and then flush serial port:
So to summarize, my questions are as following:
1. Why would device reboot when connecting via Raspberry PI
2. How to flush serial port properly?
serialPort = serial.Serial()
serialPort.baudrate = 115200
serialPort.bytesize = serial.EIGHTBITS
serialPort.timeout = 1
serialPort.stopbits = serial.STOPBITS_ONE
serialPort.port = target_port
serialPort.rts = 0
serialPort.dtr = 0
serialPort.open()
if serialPort.is_open:
print(f"Port {target_port} is now open.")
else:
print(f"Failed to open port {target_port}.")However, the device that I am connecting to reboots. When I try to do this via my Windows machine, it does not reboot. Perhaps anyone know why this could be the case even though I have set rts and dtr to 0?Since the device reboots after connecting to the serialport, during the bootup, it prints out a bunch of garbage that I want to filter out. So I decided to sleep for 2 seconds and then flush serial port:
serialPort = serial.Serial()
serialPort.baudrate = 115200
serialPort.bytesize = serial.EIGHTBITS
serialPort.timeout = 1
serialPort.stopbits = serial.STOPBITS_ONE
serialPort.port = target_port
serialPort.rts = 0
serialPort.dtr = 0
serialPort.open()
if serialPort.is_open:
print(f"Port {target_port} is now open.")
else:
print(f"Failed to open port {target_port}.")
time.sleep(2)
serialPort.flush()but that does not work. Even after flushing serial port, there is still bunch of logs accumulated. How can I ensure the serial port is flushed?So to summarize, my questions are as following:
1. Why would device reboot when connecting via Raspberry PI
2. How to flush serial port properly?
