Skip to content

Commit

Permalink
Add first tests for nfc/clf/rcs380.py
Browse files Browse the repository at this point in the history
  • Loading branch information
nehpetsde committed Mar 30, 2017
1 parent b1f7c8d commit 17ae369
Show file tree
Hide file tree
Showing 2 changed files with 507 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/nfc/clf/rcs380.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,10 @@
log = logging.getLogger(__name__)


class Frame():
class Frame(object):
def __init__(self, data):
self._data = None
self._type = None
self._frame = None

if data[0:3] == bytearray(b"\x00\x00\xff"):
Expand Down Expand Up @@ -113,14 +114,15 @@ def __init__(self, status_bytes):
self.errno = struct.unpack('<L', str(status_bytes))[0]

def __eq__(self, strerr):
return self.errno & CommunicationError.str2err[strerr]
errno = CommunicationError.str2err[strerr]
return bool(self.errno & errno) if self.errno or errno else True

def __ne__(self, strerr):
return not self.__eq__(strerr)

def __str__(self):
return self.__class__.__name__ + ' ' + CommunicationError.err2str.get(
self.errno, "{0:08x}".format(self.errno))
self.errno, "0x{0:08X}".format(self.errno))


class StatusError:
Expand All @@ -135,7 +137,7 @@ def __str__(self):
try:
return StatusError.err2str[self.errno]
except IndexError:
return "UNKNOWN STATUS ERROR {0:02x}".format(self.errno)
return "UNKNOWN STATUS ERROR 0x{:02X}".format(self.errno)


class Chipset(object):
Expand Down

0 comments on commit 17ae369

Please sign in to comment.