rfid imports
This commit is contained in:
parent
270366af32
commit
4bf753e50a
|
|
@ -105,7 +105,7 @@ def connect(path):
|
|||
for drv in drivers:
|
||||
for dev in devices:
|
||||
log.debug("trying {0} on {1}".format(drv, dev))
|
||||
driver = importlib.import_module("nfc.clf." + drv)
|
||||
driver = importlib.import_module("src.lib.nfc.clf." + drv)
|
||||
tty = None
|
||||
try:
|
||||
tty = transport.TTY(dev)
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ listen_dep yes
|
|||
========== ======= ============
|
||||
|
||||
"""
|
||||
import nfc.clf
|
||||
import src.lib.nfc.clf
|
||||
from . import pn53x
|
||||
|
||||
import os
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ interface chips, namely the NXP PN531, PN532, PN533 and the Sony
|
|||
RC-S956.
|
||||
|
||||
"""
|
||||
import nfc.clf
|
||||
import src.lib.nfc.clf
|
||||
from . import device
|
||||
|
||||
import os
|
||||
|
|
@ -518,7 +518,7 @@ class Device(device.Device):
|
|||
self.log.debug("disable crc check for type 2 tag")
|
||||
rxmode = self.chipset.read_register("CIU_RxMode")
|
||||
self.chipset.write_register("CIU_RxMode", rxmode & 0x7F)
|
||||
return nfc.clf.RemoteTarget(
|
||||
return src.lib.nfc.clf.RemoteTarget(
|
||||
"106A", sens_res=sens_res, sel_res=sel_res, sdd_res=sdd_res)
|
||||
|
||||
if self.chipset.read_register("CIU_FIFOData") == 0x26:
|
||||
|
|
@ -668,15 +668,15 @@ class Device(device.Device):
|
|||
except Chipset.Error as error:
|
||||
self.log.debug(error)
|
||||
if error.errno == 1:
|
||||
raise nfc.clf.TimeoutError
|
||||
raise src.lib.nfc.clf.TimeoutError
|
||||
else:
|
||||
raise nfc.clf.TransmissionError(str(error))
|
||||
raise src.lib.nfc.clf.TransmissionError(str(error))
|
||||
except IOError as error:
|
||||
self.log.debug(error)
|
||||
if not error.errno == errno.ETIMEDOUT:
|
||||
raise error
|
||||
else:
|
||||
raise nfc.clf.TimeoutError("send_cmd_recv_rsp")
|
||||
raise src.lib.nfc.clf.TimeoutError("send_cmd_recv_rsp")
|
||||
|
||||
def _tt1_send_cmd_recv_rsp(self, data, timeout):
|
||||
cname = self.__class__.__module__ + '.' + self.__class__.__name__
|
||||
|
|
|
|||
|
|
@ -423,7 +423,7 @@ class TagCommandError(Exception):
|
|||
|
||||
|
||||
def activate(clf, target):
|
||||
import nfc.clf
|
||||
import src.lib.nfc.clf
|
||||
try:
|
||||
log.debug("trying to activate {0}".format(target))
|
||||
if target.brty.endswith('A'):
|
||||
|
|
@ -437,32 +437,32 @@ def activate(clf, target):
|
|||
return activate_tt4(clf, target)
|
||||
elif target.brty.endswith('F'):
|
||||
return activate_tt3(clf, target)
|
||||
except nfc.clf.CommunicationError:
|
||||
except src.lib.nfc.clf.CommunicationError:
|
||||
return None
|
||||
|
||||
|
||||
def activate_tt1(clf, target):
|
||||
log.debug("trying type 1 tag activation for {0}".format(target.brty))
|
||||
import nfc.tag.tt1
|
||||
return nfc.tag.tt1.activate(clf, target)
|
||||
import src.lib.nfc.tag.tt1
|
||||
return src.lib.nfc.tag.tt1.activate(clf, target)
|
||||
|
||||
|
||||
def activate_tt2(clf, target):
|
||||
log.debug("trying type 2 tag activation for {0}".format(target.brty))
|
||||
import nfc.tag.tt2
|
||||
return nfc.tag.tt2.activate(clf, target)
|
||||
import src.lib.nfc.tag.tt2
|
||||
return src.lib.nfc.tag.tt2.activate(clf, target)
|
||||
|
||||
|
||||
def activate_tt3(clf, target):
|
||||
log.debug("trying type 3 tag activation for {0}".format(target.brty))
|
||||
import nfc.tag.tt3
|
||||
return nfc.tag.tt3.activate(clf, target)
|
||||
import src.lib.nfc.tag.tt3
|
||||
return src.lib.nfc.tag.tt3.activate(clf, target)
|
||||
|
||||
|
||||
def activate_tt4(clf, target):
|
||||
log.debug("trying type 4 tag activation for {0}".format(target.brty))
|
||||
import nfc.tag.tt4
|
||||
return nfc.tag.tt4.activate(clf, target)
|
||||
import src.lib.nfc.tag.tt4
|
||||
return src.lib.nfc.tag.tt4.activate(clf, target)
|
||||
|
||||
|
||||
class TagEmulation(object):
|
||||
|
|
@ -471,10 +471,10 @@ class TagEmulation(object):
|
|||
|
||||
|
||||
def emulate(clf, target):
|
||||
import nfc.clf
|
||||
assert isinstance(target, nfc.clf.LocalTarget)
|
||||
import src.lib.nfc.clf
|
||||
assert isinstance(target, src.lib.nfc.clf.LocalTarget)
|
||||
if target.tt3_cmd:
|
||||
import nfc.tag.tt3
|
||||
return nfc.tag.tt3.Type3TagEmulation(clf, target)
|
||||
import src.lib.nfc.tag.tt3
|
||||
return src.lib.nfc.tag.tt3.Type3TagEmulation(clf, target)
|
||||
else:
|
||||
log.debug("can't emulate with %s", target)
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ from binascii import hexlify
|
|||
from struct import pack, unpack
|
||||
|
||||
from . import Tag, TagCommandError
|
||||
import nfc.clf
|
||||
import src.lib.nfc.clf
|
||||
|
||||
import logging
|
||||
log = logging.getLogger(__name__)
|
||||
|
|
@ -489,7 +489,7 @@ class Type2Tag(Tag):
|
|||
self.target.sel_req = self.target.sdd_res[:]
|
||||
self._target = self.clf.sense(self.target)
|
||||
raise Type2TagCommandError(
|
||||
INVALID_PAGE_ERROR if self.target else nfc.tag.RECEIVE_ERROR)
|
||||
INVALID_PAGE_ERROR if self.target else src.lib.nfc.tag.RECEIVE_ERROR)
|
||||
|
||||
if len(data) != 16:
|
||||
log.debug("invalid response %s", hexlify(data).decode())
|
||||
|
|
@ -583,7 +583,7 @@ class Type2Tag(Tag):
|
|||
# communication. If that failed (tag gone) then any
|
||||
# further attempt to transceive() is the same as
|
||||
# "unrecoverable timeout error".
|
||||
raise Type2TagCommandError(nfc.tag.TIMEOUT_ERROR)
|
||||
raise Type2TagCommandError(src.lib.nfc.tag.TIMEOUT_ERROR)
|
||||
|
||||
started = time.time()
|
||||
error = None
|
||||
|
|
@ -591,17 +591,17 @@ class Type2Tag(Tag):
|
|||
try:
|
||||
data = self.clf.exchange(data, timeout)
|
||||
break
|
||||
except nfc.clf.CommunicationError as e:
|
||||
except src.lib.nfc.clf.CommunicationError as e:
|
||||
error = e
|
||||
reason = error.__class__.__name__
|
||||
log.debug("%s after %d retries" % (reason, retry))
|
||||
else:
|
||||
if type(error) is nfc.clf.TimeoutError:
|
||||
raise Type2TagCommandError(nfc.tag.TIMEOUT_ERROR)
|
||||
if type(error) is nfc.clf.TransmissionError:
|
||||
raise Type2TagCommandError(nfc.tag.RECEIVE_ERROR)
|
||||
if type(error) is nfc.clf.ProtocolError:
|
||||
raise Type2TagCommandError(nfc.tag.PROTOCOL_ERROR)
|
||||
if type(error) is src.lib.nfc.clf.TimeoutError:
|
||||
raise Type2TagCommandError(src.lib.nfc.tag.TIMEOUT_ERROR)
|
||||
if type(error) is src.lib.nfc.clf.TransmissionError:
|
||||
raise Type2TagCommandError(src.lib.nfc.tag.RECEIVE_ERROR)
|
||||
if type(error) is src.lib.nfc.clf.ProtocolError:
|
||||
raise Type2TagCommandError(src.lib.nfc.tag.PROTOCOL_ERROR)
|
||||
raise RuntimeError("unexpected " + repr(error))
|
||||
|
||||
elapsed = time.time() - started
|
||||
|
|
@ -686,8 +686,8 @@ def activate(clf, target):
|
|||
# sel_req we ensure that only the same tag will be found.
|
||||
target.sel_req = target.sdd_res[:]
|
||||
if target.sdd_res[0] == 0x04: # NXP
|
||||
import nfc.tag.tt2_nxp
|
||||
tag = nfc.tag.tt2_nxp.activate(clf, target)
|
||||
import src.lib.nfc.tag.tt2_nxp
|
||||
tag = src.lib.nfc.tag.tt2_nxp.activate(clf, target)
|
||||
if tag is not None:
|
||||
return tag
|
||||
else:
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
# See the Licence for the specific language governing
|
||||
# permissions and limitations under the Licence.
|
||||
# -----------------------------------------------------------------------------
|
||||
import nfc.clf
|
||||
import src.lib.nfc.clf
|
||||
from . import tt2
|
||||
|
||||
import os
|
||||
|
|
@ -742,10 +742,10 @@ def activate(clf, target):
|
|||
return
|
||||
if rsp.startswith(b"\xAF"):
|
||||
return MifareUltralightC(clf, target)
|
||||
except nfc.clf.TimeoutError:
|
||||
except src.lib.nfc.clf.TimeoutError:
|
||||
if clf.sense(target) is None:
|
||||
return
|
||||
except nfc.clf.CommunicationError as error:
|
||||
except src.lib.nfc.clf.CommunicationError as error:
|
||||
log.debug(repr(error))
|
||||
return
|
||||
|
||||
|
|
@ -761,10 +761,10 @@ def activate(clf, target):
|
|||
return NTAG203(clf, target)
|
||||
log.debug("no match for version %s", hexlify(rsp).decode().upper())
|
||||
return
|
||||
except nfc.clf.TimeoutError:
|
||||
except src.lib.nfc.clf.TimeoutError:
|
||||
if clf.sense(target) is None:
|
||||
return
|
||||
except nfc.clf.CommunicationError as error:
|
||||
except src.lib.nfc.clf.CommunicationError as error:
|
||||
log.debug(repr(error))
|
||||
return
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user