Now, "Send a break signal automatically and finish processing when prompted."
I am thinking of the code
I can't write "Finish the process when you get a prompt" in it.
How should I write the code to stop?
Thank you very much for letting me know.
environment
Python 3.6.8
pyserial 3.4
import sys
import serial
import time
ser=serial.Serial(
port = 'COM1',
baudrate=115200,
parity = 'N',
stopbits = 1,
bytesize = 8,
timeout = 8
)
ser.isOpen()
while True:
ser.send_break()
command='\r\n'
out=ser.readline()
out=out.decode("utf-8", "ignore")
time.sleep(0.5)
if out=='>':
sys.exit()
ser.isOpen()
The serial port may not be open.
© 2024 OneMinuteCode. All rights reserved.