Exemple #1
0
 def __init__(self, id, function, values=None):
     buffer = array.array('B')
     buffer.append(id)
     buffer.append(function)
     if not values is None:
         buffer.append(len(values))
         buffer.fromlist(values)
     self.buffer = buffer.tostring()
Exemple #2
0
 def append_crc(self):
     #append a crc character to an existing response string
     buffer = array.array('B')
     buffer.fromstring(self.buffer)
     x = crc(buffer)
     buffer.append(x & 0xFF)
     buffer.append(x >> 8)
     self.crc = x
     self.buffer = buffer.tostring()
Exemple #3
0
 def __init__(self, id, function, error_code):
     buffer = array.array('B')
     buffer.append(id)
     buffer.append(function)
     buffer.append(error_code)
     self.buffer = buffer.tostring()