From cca187ca5160d326a838f1cdf07a4d816b66b16b Mon Sep 17 00:00:00 2001
From: 488_MP-4 <488_MP-4@iastate.edu>
Date: Wed, 25 Oct 2023 23:48:27 +0200
Subject: [PATCH] new thread for output

---
 .../crazyflie_connection.cpython-38.pyc       | Bin 5887 -> 5921 bytes
 .../groundstation_socket.cpython-38.pyc       | Bin 4722 -> 4710 bytes
 cflib_groundstation/main.py                   |  51 ++++++++++--------
 3 files changed, 29 insertions(+), 22 deletions(-)

diff --git a/cflib_groundstation/__pycache__/crazyflie_connection.cpython-38.pyc b/cflib_groundstation/__pycache__/crazyflie_connection.cpython-38.pyc
index c4249331c166cdd16323d98a46de616822643865..95e0b2d206542122c47f17c1bc791704cb6a436a 100644
GIT binary patch
delta 221
zcmeybyHJlel$V!_0SH!iS*G6F$a|AT(nUWbKQ~oBDYGQGD6uM4-#0V4DBsyJC}cA?
z>sMAY#$X0brYgPQ)V!2pg~Xg3h2qqbg8a<9l46Cl{33-!h4jp_)I5d6-2BqK5{3LU
zg_6wNRKLmjLQ<2JxFwibsuU+L6cU*n$Q{cVzIi>j6BA?P<WIam8S^*4;ge-zESbzD
zIGu6wWPV|V$%h0Z7^ebR%9HJc!WgGdUeB#Cd8<$)<4mAfIpgff?ZTyub0_}=vgc1O
U6{%-jwE3$DCnF>4;{T$I08LIw3jhEB

delta 178
zcmZ3e_g|Mcl$V!_0SH{`EmN;-<h{wF8laz%pPQ<mlv$EolvtIj?~+=aU6Nm*pI($-
znwL^sl30?NpSSrx%U9OP0zyiYUAQHfnX42hKV%Y~T*Mv67`FK$w-Xa%#AFe^pNx5%
z`S@j-7>g(C2u^35G}%yCVe%8f2*xQumh$8Tp)kg2lP_{BOujA@$v6WjR?awU@=D=S
e#yOMaMamiHO`a}N&$w{2xF{zhBg<k%F-8ES3pu0!

diff --git a/cflib_groundstation/__pycache__/groundstation_socket.cpython-38.pyc b/cflib_groundstation/__pycache__/groundstation_socket.cpython-38.pyc
index 8a732cdc4af311c7f155b3d8ce0fe128b8971509..39e080287b02284dc8b442133a25e79e43321bd7 100644
GIT binary patch
delta 50
zcmeyQ@=S#*l$V!_0SI2WZRDzDk#y0|$j?pHPs%JwE=sIQ)%VRzF3NXy3<}x2hUFM9
E0DzJZPXGV_

delta 62
zcmaE+@=1j&l$V!_0SN3WHgeUns0Qd~<maa9CuNo-7bRAu>bs;CXP4v`=%*Lum*%Au
Qmn4>C=I3o*z;cWi09W%BSpWb4

diff --git a/cflib_groundstation/main.py b/cflib_groundstation/main.py
index 4f6d633d7..70adb824c 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
-- 
GitLab