In [2]:
from binascii import a2b_hex as a2b
from binascii import b2a_hex as b2a

In [3]:
# Direkte CRC-Berechnung
from implib2.imp_crc import MaximCRC
crc = MaximCRC()

print b2a(crc.calc_crc(a2b('FF00')))
print crc.check_crc(a2b('FD2A03D37F00A6'))


81
True

In [6]:
# Packete ein und auspacken
from implib2.imp_packages import Package, PackageError
pkg = Package()

data = a2b('00D37F0078')
pkg.unpack(data)


---------------------------------------------------------------------------
error                                     Traceback (most recent call last)
<ipython-input-6-92a6936c792a> in <module>()
      4 
      5 data = a2b('00D37F0078')
----> 6 pkg.unpack(data)

/Users/markus/Development/implib2/implib2/imp_packages.pyc in unpack(self, package)
     86 
     87     def unpack(self, package):
---> 88         header = self._unpack_head(package[:7])
     89         data = None
     90 

/Users/markus/Development/implib2/implib2/imp_packages.pyc in _unpack_head(self, header)
     63         cmd = struct.unpack('<B', header[1])[0]
     64         length = struct.unpack('<B', header[2])[0]
---> 65         serno = struct.unpack('<I', header[3:6] + '\x00')[0]
     66 
     67         if not self.crc.check_crc(header):

error: unpack requires a string argument of length 4

In [ ]: