等待磁条卡的串行响应
我是 Python 编程新手,我需要一些关于这个小应用程序的帮助。
我编写了一个小应用程序来生成随机代码并将其写入磁条卡。
读卡器是MSR206u,通过串口连接,我可以读取和读取数据。写入卡编码器,但我需要等待编码器的确认。
当我发送到编码器进行写入时,它写入正常,但我不知道如何“等待”编码器的响应。
感谢您的帮助!
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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您只需在配置了适当超时的情况下在串行端口上进行读取即可等待响应。读取超时和字符间超时都可以在 serial.Serial 类的构造函数中指定来自pyserial。
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.