mirror of
https://github.com/CopterExpress/clever-show.git
synced 2026-05-30 16:59:32 +00:00
Little fixes
This commit is contained in:
@@ -207,7 +207,7 @@ def selfcheck():
|
||||
|
||||
def write_to_config(section, option, value):
|
||||
config.set(section, option, value)
|
||||
with open(CONFIG_PATH, 'w') as file:
|
||||
with open(CONFIG_PATH, 'w') as file: # TODO as separate function
|
||||
config.write(file)
|
||||
|
||||
|
||||
@@ -272,14 +272,14 @@ try:
|
||||
command, args = parse_message(message)
|
||||
print("Command from server:", command, args)
|
||||
if command == "writefile":
|
||||
recive_file(list(args.values())[0])
|
||||
recive_file(args['filename'])
|
||||
elif command == 'config_write':
|
||||
write_to_config(args['section'], args['option'], args['value'])
|
||||
elif command == 'config_reload':
|
||||
load_config()
|
||||
elif command == "starttime":
|
||||
global starttime
|
||||
starttime = float(list(args.values())[0])
|
||||
starttime = float(args['time'])
|
||||
print("Starting on:", time.ctime(starttime))
|
||||
dt = starttime - time.time()
|
||||
if USE_NTP:
|
||||
@@ -310,8 +310,13 @@ try:
|
||||
response = COPTER_ID
|
||||
elif request_target == 'selfcheck':
|
||||
response = selfcheck()
|
||||
send_all(bytes(form_message("response", {"status": "ok", "value": response})))
|
||||
elif request_target == 'batt_voltage':
|
||||
pass # TODO
|
||||
|
||||
send_all(bytes(form_message("response",
|
||||
{"status": "ok", "value": response, "value_name": request_target})))
|
||||
print("Request responded with:", response)
|
||||
|
||||
except socket.error as e:
|
||||
if e.errno != errno.EINTR:
|
||||
print("Connection lost due error:", e)
|
||||
|
||||
@@ -31,6 +31,7 @@ def animate_frame(current_frame, x0=0.0, y0=0.0):
|
||||
if USE_LEDS:
|
||||
LedLib.fill(current_frame['red'], current_frame['green'], current_frame['blue'])
|
||||
|
||||
|
||||
def reach_frame(current_frame, x0=0.0, y0=0.0, timeout=5000):
|
||||
FlightLib.reach_point(current_frame['x']+x0, current_frame['y']+y0, current_frame['z'], yaw=1.57, timeout=timeout) # TODO yaw
|
||||
if USE_LEDS:
|
||||
|
||||
@@ -17,7 +17,7 @@ random.seed()
|
||||
|
||||
logging.basicConfig( # TODO all prints as logs
|
||||
level=logging.INFO,
|
||||
format="%(asctime)s [%(name)-7.7s] [%(threadName)-18.18s] [%(levelname)-7.7s] %(message)s",
|
||||
format="%(asctime)s [%(name)-7.7s] [%(threadName)-19.19s] [%(levelname)-7.7s] %(message)s",
|
||||
handlers=[
|
||||
logging.FileHandler("server_logs.log"),
|
||||
logging.StreamHandler()
|
||||
@@ -283,10 +283,12 @@ class Client:
|
||||
command, args = Client.parse_message(received)
|
||||
if command == "response":
|
||||
for key, value in self._request_queue.items():
|
||||
if not value: # TODO redo to value name
|
||||
if not value and key == args["value_name"]:
|
||||
self._request_queue[key] = args['value']
|
||||
print("Request successfully closed")
|
||||
break
|
||||
else:
|
||||
print("Unexpected request")
|
||||
else:
|
||||
self._received_queue.appendleft(received)
|
||||
except socket.error:
|
||||
|
||||
Reference in New Issue
Block a user