Example #1
0
 def _get_frame(self, sock):
     hdr_bytes = _recvall(sock, Command.HDR_LEN)
     hdr = Command.from_bytes(hdr_bytes)
     body_bytes = _recvall(sock, hdr.get_arg(Command.HDR_ARG_BODYSZ))
     if hdr.cmdtype == CommandType.heartbeat:
         # ignore heartbeat responses and just get next frame
         return self._get_frame(sock)
     if hdr.cmdtype == CommandType.retreplayend:
         return None
     return body_bytes
Example #2
0
 def _send_cmd(self, cmd):
     t = LWDrone._CONNECT_TIMEOUT
     with socket.create_connection(self._cmd_addr, timeout=t) as sock:
         cmd_bytes = cmd.to_bytes()
         sock.sendall(cmd_bytes)
         hdr_bytes = _recvall(sock, Command.HDR_LEN)
         hdr = Command.from_bytes(hdr_bytes)
         body_bytes = _recvall(sock, hdr.get_arg(Command.HDR_ARG_BODYSZ))
         hdr.body = body_bytes
     return hdr