Search code examples
pythonmagnetic-cards

Wait Serial response from magstrip card


I'm new programing in Python, and what I need a little help with this little aplication.

I write a little aplication that generate a random code and write it to the magstrip card.

The card reader is a MSR206u and is connected by serial port, I can read & write to the card encoder, but I need to wait for the confirmation from the encoder.

When I send to the encoder to write, it write OK, but I dont know how to "wait" to the response from the encoder.

Thanks for your help!


Solution

  • You can wait for the response by simply doing a read on the serial port with an appropriate timeout configured. Both the read and inter-character timeouts may be specified in the constructor of the serial.Serial class from pyserial.