Ejemplo n.º 1
0
 def __hex__(self):
     return "%(title)s00%(type)s%(altitude)s0000%(latitude)s%(longitude)s" % {
         'latitude'  : Utilities.swap(hex(self.latitude)),
         'longitude' : Utilities.swap(hex(self.longitude)),
         'altitude'  : Utilities.swap(Utilities.dec2hex(self.altitude,4)),
         'type'      : Utilities.dec2hex(self.type,2),
         'title'     : Utilities.chr2hex(self.title.ljust(6)[:6])
     }
Ejemplo n.º 2
0
    def _readPayload(self):
	# find the payload and read the exact number of bytes 1 at a time
	# much faster than guessing at it and waiting for the timeout
	# byte by byte improves flow control/buffer overruns in linux	
        raw = ''
        data = Utilities.chr2hex(self.serial.read(3))
        if data:
            payload = int(data[2:6], 16)
            if payload > 0:
                for i in range (0, payload):
                    raw += self.serial.read()

            # read the last checksum byte
            raw += self.serial.read()
            
            data += Utilities.chr2hex(raw)
            self.logger.debug("serial port returned: %s" % data if len(data) < 30 else "%s... (truncated)" % data[:30])
            #self.logger.debug("serial port returned: %s" % data)
            return data
        else:
            return None
Ejemplo n.º 3
0
 def _read(self, size = 2070):
     data = Utilities.chr2hex(self.serial.read(size))
     #self.logger.debug("serial port returned: %s" % data if len(data) < 30 else "%s... (truncated)" % data[:30])
     self.logger.debug("serial port returned: %s" % data)
     return data