packet.py 484 B

123456789101112131415161718
  1. import constants
  2. class Packet(object):
  3. def __init__(self, contents):
  4. self.type = "Z" # Type Code (see protocol)
  5. self.address = "00" # Sign Address (see protocol)
  6. self._pkt = ("%s%s%s%s%s%s%s" %
  7. (constants.NUL * 5, constants.SOH, self.type,
  8. self.address, constants.STX, contents,
  9. constants.EOT))
  10. def __str__(self):
  11. return self._pkt
  12. def __repr__(self):
  13. return repr(self._pkt)