def main(args):
print("This is the %s version of nfcpy run in Python %s\non %s" %
(nfc.__version__, platform.python_version(), platform.platform()))
print("I'm now searching your system for contactless devices")
found = 0
for vid, pid, bus, dev in nfc.clf.transport.USB.find("usb"):
if (vid, pid) in nfc.clf.device.usb_device_map:
path = "usb:{0:03d}:{1:03d}".format(bus, dev)
try:
clf = nfc.ContactlessFrontend(path)
print("** found %s" % clf.device)
clf.close()
found += 1
except IOError as error:
if error.errno == errno.EACCES:
usb_device_access_denied(bus, dev, vid, pid, path)
elif error.errno == errno.EBUSY:
usb_device_found_is_busy(bus, dev, vid, pid, path)
if args.search_tty:
for dev in nfc.clf.transport.TTY.find("tty")[0]:
path = "tty:{0}".format(dev[8:])
try:
clf = nfc.ContactlessFrontend(path)
print("** found %s" % clf.device)
clf.close()
found += 1
except IOError as error:
if error.errno == errno.EACCES:
print("access denied for device with path %s" % path)
elif error.errno == errno.EBUSY:
print("the device with path %s is busy" % path)
else:
print("I'm not trying serial devices because you haven't told me")
print("-- add the option '--search-tty' to have me looking")
print("-- but beware that this may break other serial devs")
if not found:
print("Sorry, but I couldn't find any contactless device")
评论列表
文章目录