pySerial readline reads previously written data

Viewed 857

Hy,

I am writing some data through serial port, and i have an issue reading the response from that device.

Example:

ser.write('Hello World')
print(ser.readline()) #Instead of reading the response from the 
                      #other device, it reads 'Hello world'

I have made a workaround for this issue, by calling twice the readline(), and not caring about the first one. In this way (works) it reads the data sent from the other device

ser.write('Hello World')
ser.readline()
print(ser.readline())

It seems for me that the data sent it remains in the buffer? and when calling readline() it reds that first?!

Can somebody explain for me what i am doing wrong?

Thank you!

1 Answers
Related