How do I do a proper if statement with data from a serial device in python?

33 views Asked by At

I'm reading in serial data from a serial USB device with python. I want to compare the received data with a predefined string if it matches. Reading the data works fine the problem is this if-statement:

if serialInst.in_waiting:
    startPacket =  serialInst.readline()    
    z = "iohioowwcncuewqrte"
    k = startPacket.decode('utf').rstrip('\n')
    if (k == z):
        print("right passkey")
    else:
        print("Error") 
        exit()

Thank you in advance.

0

There are 0 answers