0

m trying to create a tool that help to simulate key press

but at part of this code mentioned below, the program gets stuck and its not proceeding

ser = serial.Serial(ACM)
ser.baudrate = 115200
ser.timeout = None
ser.flushInput()
ser.flushOutput()
ser.write(cmd)
p = ser.readline()
pr = p.decode("utf-8")
print(cmd)
print(pr)
ser.close()
print("Closed")

" ser.readline() is not reading the output of serial com /dev/ttyACM*

Thanks

1 Answer 1

1

The PySerial documentation is unmistakable:

Be careful when using readline(). Do specify a timeout when opening the serial port otherwise it could block forever if no newline character is received.

You define: ser.timeout = None so what exactly do you expect your program to do, but block forever if you don't receive a newline?

Either make sure the sent lines are terminated or use a reasonable timeout.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.