diff --git a/cflib_groundstation/__pycache__/crazyflie_connection.cpython-38.pyc b/cflib_groundstation/__pycache__/crazyflie_connection.cpython-38.pyc index c4249331c166cdd16323d98a46de616822643865..95e0b2d206542122c47f17c1bc791704cb6a436a 100644 Binary files a/cflib_groundstation/__pycache__/crazyflie_connection.cpython-38.pyc and b/cflib_groundstation/__pycache__/crazyflie_connection.cpython-38.pyc differ diff --git a/cflib_groundstation/__pycache__/groundstation_socket.cpython-38.pyc b/cflib_groundstation/__pycache__/groundstation_socket.cpython-38.pyc index 8a732cdc4af311c7f155b3d8ce0fe128b8971509..39e080287b02284dc8b442133a25e79e43321bd7 100644 Binary files a/cflib_groundstation/__pycache__/groundstation_socket.cpython-38.pyc and b/cflib_groundstation/__pycache__/groundstation_socket.cpython-38.pyc differ diff --git a/cflib_groundstation/main.py b/cflib_groundstation/main.py index 4f6d633d7bfbfd1668c30fdda3d454b7d6bb4e71..70adb824ce2c89450ac49fdf93315b0f5978c8f5 100644 --- a/cflib_groundstation/main.py +++ b/cflib_groundstation/main.py @@ -1,3 +1,4 @@ +from ast import While from email import message from queue import Queue from threading import Thread @@ -11,12 +12,19 @@ class main(): self.outputQueue = Queue() - - def processCommands(self): + def start(self): gs = GroundstationSocket() self.inThread = Thread(target = gs.groundstation_connect, args = (self.inputQueue,)) self.inThread.start() - cfConnect = CrazyflieConnection() + self.cfConnect = CrazyflieConnection() + self.commandThread = Thread(target = self.processCommands) + self.commandThread.start() + while True: + if self.outputQueue.not_empty: + message = self.outputQueue.get() + gs.WriteToBackend(message) + + def processCommands(self): while True: if self.inputQueue.not_empty: command = self.inputQueue.get() @@ -24,40 +32,39 @@ class main(): msg_type = command["msg_type"] print(msg_type) if msg_type == MessageTypeID.GETPACKETLOGS_ID.value: - cfConnect.GetPacketLogs() + self.cfConnect.GetPacketLogs() elif msg_type == MessageTypeID.UPDATE_ID.value: - cfConnect.Update() + self.cfConnect.Update() elif msg_type == MessageTypeID.BEGINUPDATE_ID.value: - cfConnect.BeginUpdate() + self.cfConnect.BeginUpdate() elif msg_type == MessageTypeID.OUTPUT_OVERRIDE_ID.value: - cfConnect.OverrideOuput() + self.cfConnect.OverrideOuput() elif msg_type == MessageTypeID.GETNODES_ID.value: - cfConnect.GetNodes() + self.cfConnect.GetNodes() elif msg_type == MessageTypeID.SETPARAM_ID.value: - cfConnect.SetParam() + self.cfConnect.SetParam() elif msg_type == MessageTypeID.GETPARAM_ID.value: - cfConnect.GetParam() + self.cfConnect.GetParam() elif msg_type == MessageTypeID.SETSOURCE_ID.value: - cfConnect.SetSource() + self.cfConnect.SetSource() elif msg_type == MessageTypeID.GETSOURCE_ID.value: - cfConnect.GetSource() + self.cfConnect.GetSource() elif msg_type == MessageTypeID.RESPSOURCE_ID.value: - cfConnect.RespSource() + self.cfConnect.RespSource() elif msg_type == MessageTypeID.GETOUTPUT_ID.value: - cfConnect.GetOutput() + self.cfConnect.GetOutput() elif msg_type == MessageTypeID.GETNODES_ID.value: - cfConnect.GetNodes() + self.cfConnect.GetNodes() elif msg_type == MessageTypeID.ADDNODE_ID.value: - cfConnect.AddNode() + self.cfConnect.AddNode() elif msg_type == MessageTypeID.LOG_ID.value: - cfConnect.GetLogFile() + self.cfConnect.GetLogFile() elif msg_type == MessageTypeID.LOG_END_ID.value: - cfConnect.LogBlockCommand() + self.cfConnect.LogBlockCommand() + - if self.outputQueue.not_empty: - message = self.outputQueue.get() - gs.WriteToBackend(message) + @@ -65,6 +72,6 @@ class main(): if __name__ == '__main__': - main().processCommands() + main().start() \ No newline at end of file