コード例 #1
0
 def format(self):
     params = self.params
     code = self.code
     maxRetries = self.retries
     serial = list(bytearray(self.serial.decode('hex')))
     paramsCount = len(params)
     head = [1, 0, 167, 1]
     # serial
     packet = head + serial
     # paramCount 2 bytes
     packet.extend([(0x80 | lib.HighByte(paramsCount)),
                    lib.LowByte(paramsCount)])
     # not sure what this byte means
     button = 0
     # special case command 93
     if code == 93:
         button = 85
     packet.append(button)
     packet.append(maxRetries)
     # how many packets/frames/pages/flows will this take?
     responseSize = self.calcRecordsRequired()
     # really only 1 or 2?
     pages = responseSize
     if responseSize > 1:
         pages = 2
     packet.append(pages)
     packet.append(0)
     # command code goes here
     packet.append(code)
     packet.append(CRC8(packet))
     packet.extend(params)
     packet.append(CRC8(params))
     log.debug(packet)
     return bytearray(packet)
コード例 #2
0
ファイル: stick.py プロジェクト: xiali1/decoding-carelink
 def __init__(self, size):
   self.size = size
   self.dl_size = size
   packet = [12, 0, lib.HighByte(size), lib.LowByte(size)]
   if size < 64:
     log.error('size is less than 64, which will cause an error. trying 64 instead')
     self.size = 64
   self.code = packet + [ CRC8(packet) ]
コード例 #3
0
 def __init__(self, size):
     self.size = size
     self.dl_size = size
     packet = [12, 0, lib.HighByte(size), lib.LowByte(size)]
     if size < 64 and size != 15:
         log.error(
             'size (%s) is less than 64 and not 15, which may cause an error.'
             % size)
         self.size = 64
     self.code = packet + [CRC8(packet)]
コード例 #4
0
 def fmt_datetime (klass, dt):
   return [dt.hour, dt.minute, dt.second, lib.HighByte(dt.year), lib.LowByte(dt.year), dt.month, dt.day]