def set_fail_position(controller): for i in range(8): val = int(remote_config.get("fail", "{}".format(i))) controller.set_position(i, int(range_convert(-100, 100, 1000, 2000, val)))
data = struct.unpack("<IBBBBB", packet.buffer[6:6 + self.pl_length]) self.custom_mode = data[0] self.type = data[1] self.autopilot = data[2] self.base_mode = data[3] self.system_status = data[4] self.mavlink_version = data[5] def set_fail_position(controller): for i in range(8): val = int(remote_config.get("fail", "{}".format(i))) controller.set_position(i, int(range_convert(-100, 100, 1000, 2000, val))) if __name__ == '__main__': controller = PCA9685(0, 0x40) host = remote_config.get("remote_udp", "ip") port = int(remote_config.get("remote_udp", "port")) s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) s.bind((host, port)) s.setsockopt(socket.SOL_SOCKET, socket.SO_RCVBUF, 2048) s.setblocking(False) last_heartbeat = 0 fail = False next_run = time.time() + 0.02 while True: if time.time() > next_run: next_run += 0.02 read, write, error = select.select([s], [], [], 0.1) if len(read) > 0: buffer = read[0].recvfrom(256) tmpPacket = Packet(buffer[0])
self.autopilot = data[2] self.base_mode = data[3] self.system_status = data[4] self.mavlink_version = data[5] def set_fail_position(controller): for i in range(8): val = int(remote_config.get("fail", "{}".format(i))) controller.set_position(i, int(range_convert(-100, 100, 1000, 2000, val))) if __name__ == '__main__': controller = PCA9685(0, 0x40) host = remote_config.get("remote_udp", "ip") port = int(remote_config.get("remote_udp", "port")) s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) s.bind((host, port)) s.setsockopt(socket.SOL_SOCKET, socket.SO_RCVBUF, 2048) s.setblocking(False) last_heartbeat = 0 fail = False next_run = time.time() + 0.02 while True: if time.time() > next_run: next_run += 0.02 read, write, error = select.select([s], [], [], 0.1) if len(read) > 0: buffer = read[0].recvfrom(256) tmpPacket = Packet(buffer[0])