我正在使用这个Mercury API https://github.com/gotthardp/python-mercuryapi来读取RFID标签。在
运行下面的简单示例代码时,代码在成功执行1后会产生错误:
#!/usr/bin/env python3
from __future__ import print_function
import time
import mercury
reader = mercury.Reader("tmr:///dev/ttyUSB0", baudrate=115200)
print(reader.get_model())
print(reader.get_supported_regions())
reader.set_region("EU3")
reader.set_read_plan([1], "GEN2", read_power=1900)
print(reader.read())
reader.start_reading(lambda tag: print(tag.epc, tag.antenna, tag.read_count, tag.rssi))
time.sleep(1)
reader.stop_reading()
在第一次运行时,代码执行得很好,产生了这个RFID标签的读数。在
^{pr2}$再次运行它会导致:
Traceback (most recent call last):
File "test.py", line 5, in <module>
reader = mercury.Reader("tmr:///dev/ttyUSB0", baudrate=115200)
TypeError: No such file or directory
有时再次运行会导致:
Traceback (most recent call last):
File "test.py", line 5, in <module>
reader = mercury.Reader("tmr:///dev/ttyUSB0", baudrate=115200)
TypeError: Permission denied
然后从sudo运行它会得到RuntimeError:
M6e Nano
[u'NA2', u'NA3', u'IN', u'JP', u'PRC', u'EU3', u'KR2', u'AU', u'NZ', u'open']
Traceback (most recent call last):
File "test.py", line 12, in <module>
print(reader.read())
RuntimeError: Timeout
有什么办法解决这些问题吗?在
更新让读卡器打开一段时间后,同样的行为再次发生。第一次工作,然后进入类型错误。第一次使用后会改变路径“tmr:///dev/ttyUSB0”吗?在
Update尝试在Raspberry Pi3上运行它,我也遇到了同样的问题。运行时错误:超时
问题是RFID阅读器没有得到足够的能量。而不是3.3伏,我提供了5伏,这解决了问题。在
相关问题 更多 >
编程相关推荐