Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
tmp = CRC[checksum & 0xf]
checksum = (checksum >> 4) & 0xfff
checksum = checksum ^ tmp ^ CRC[(byte >> 4) & 0xf]
if checksum != reference:
raise Exception('Bad checksum (%04x / %04x)' % (checksum, reference))
class Msg(namedtuple('MsgTuple', 'definition data timestamp')):
__slots__ = ()
def parse(self):
return self.definition.message.parse(self.data, self.definition, self.timestamp)
class DataMsg(Msg): pass
class TimedMsg(Msg): pass
class Header:
__slots__ = ('__byte')
def __init__(self, byte):
self.__byte = byte
def is_timestamp(self):
return self.__byte & 0x80
def is_definition(self):
if checksum != reference:
raise Exception('Bad checksum (%04x / %04x)' % (checksum, reference))
class Msg(namedtuple('MsgTuple', 'definition data timestamp')):
__slots__ = ()
def parse(self):
return self.definition.message.parse(self.data, self.definition, self.timestamp)
class DataMsg(Msg): pass
class TimedMsg(Msg): pass
class Header:
__slots__ = ('__byte')
def __init__(self, byte):
self.__byte = byte
def is_timestamp(self):
return self.__byte & 0x80
def is_definition(self):
return self.__byte & 0x40
def local_type(self):