diff --git a/cflib_groundstation/__pycache__/crazyflie_connection.cpython-38.pyc b/cflib_groundstation/__pycache__/crazyflie_connection.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..46a66108eef65d96e5e41d73bf7defe483a5523d Binary files /dev/null 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 new file mode 100644 index 0000000000000000000000000000000000000000..704af640fbe957aa1ab2b02b8e7b8d6685ee8597 Binary files /dev/null and b/cflib_groundstation/__pycache__/groundstation_socket.cpython-38.pyc differ diff --git a/cflib_groundstation/groundstation_socket.py b/cflib_groundstation/groundstation_socket.py index f0c15296d90212ed3a324b1561efe02d6fa7a8ad..803726dc388e6779d0ff385704b625e8c89b6632 100644 --- a/cflib_groundstation/groundstation_socket.py +++ b/cflib_groundstation/groundstation_socket.py @@ -1,3 +1,4 @@ +from queue import Queue import socket import os import collections @@ -8,7 +9,7 @@ socket_path = './cflib_groundstation.socket' class GroundstationSocket(): metadata = collections.namedtuple("metadata", ["msg_type", "msg_id", "data_len"]) - def groundstation_connect(self): + def groundstation_connect(self, inputQueue: Queue): # remove the socket file if it already exists try: os.unlink(socket_path) @@ -45,8 +46,9 @@ class GroundstationSocket(): print("There was an error decoding the packet") break - #TODO: Add the message to the main function queue, which will + #Add the message to the main function queue, which will #which will send the appropriate command to the quad. + inputQueue.put(message) finally: # close the connection self.connection.close() @@ -149,7 +151,6 @@ class MessageTypeID(Enum): SEND_RT_ID = 20 MAX_TYPE_ID = 21 -if __name__ == '__main__': - GroundstationSocket().groundstation_connect() + diff --git a/cflib_groundstation/main.py b/cflib_groundstation/main.py index a7d3ccd07c564fcef29c554c138729906238e700..76e489c3ccd8114f6f0e443c8ad899dad27fe59c 100644 --- a/cflib_groundstation/main.py +++ b/cflib_groundstation/main.py @@ -1,5 +1,34 @@ - +from email import message +from queue import Queue +from threading import Thread +from groundstation_socket import GroundstationSocket +from crazyflie_connection import CrazyflieConnection class main(): - print("main") \ No newline at end of file + def __init__(self) -> None: + self.inputQueue = Queue() + self.outputQueue = Queue() + + + + def processCommands(self): + gs = GroundstationSocket() + self.inThread = Thread(target = gs.groundstation_connect, args = (self.inputQueue,)) + self.inThread.start() + while True: + if self.inputQueue.not_empty: + command = self.inputQueue.get() + print(command) + msg_type = command["msg_type"] + print(msg_type) + + + + + + +if __name__ == '__main__': + main().processCommands() + + \ No newline at end of file