Problems while communicating with PPK2 using a serial port

 I am having problems communication with PPK2 using pySerial library. Below is an example of code causing the error. When I try to request metadata twice during the same connection PPK ignores the second one and returns nothing. Is this intended? Is there a workaround?

import serial


if __name__ == '__main__':
    ser = serial.Serial("COM4", baudrate=115200)
    ser.write(b"\x19") #\x0A\x0D
    r=ser.readline()
    print(r)
    while not str(r) == "b'END\\n'":
        r=ser.readline()
        print(r)
    time.sleep(1)

    ser.write(b"\x19")
    print("response")
    r = ser.readline()
    print(r)
    while not str(r) == "b'END\\n'":
        r = ser.readline()
        print(r)
    ser.close()

Parents Reply Children
Related