@@ -120,9 +120,7 @@ def ota_task_queue_handler(self):
120120 # Send out REQs until a base station is found
121121 def ota_connect_req (self ):
122122 if self .ota_connected :
123- logger .warning (
124- f"connect_ota_req: OTA device is already connected to base station { self .ota_base_station_id } "
125- )
123+ logger .warning (f"connect_ota_req: OTA device is already connected to base station { self .ota_base_station_id } " )
126124 return
127125
128126 # See if there are any new messages from the OTA device
@@ -144,14 +142,10 @@ def ota_connect_req(self):
144142 if parts [2 ].startswith (
145143 "CON:"
146144 ): # TY This checks to see if the received message matches a base station connecting
147- if (
148- parts [0 ] == parts [2 ][4 :]
149- ): # format. If it does we are now going to be in the connected state
145+ if parts [0 ] == parts [2 ][4 :]: # format. If it does we are now going to be in the connected state
150146 self .ota_connected = True
151147 self .ota_base_station_id = int (parts [0 ])
152- logger .info (
153- f"ota_connect_req: OTA device connected to base station { self .ota_base_station_id } "
154- )
148+ logger .info (f"ota_connect_req: OTA device connected to base station { self .ota_base_station_id } " )
155149 self .ota_timeout = TIMEOUT
156150 self .ota .send_ota_message (self .ota_base_station_id , "ACK" )
157151 return
@@ -164,15 +158,11 @@ def ota_connect_req(self):
164158 logger .error ("ota_connect_req: Error parsing OTA message" )
165159 continue
166160
167- self .ota_base_station_id = (
168- 0 if self .ota_base_station_id is None else self .ota_base_station_id
169- )
161+ self .ota_base_station_id = 0 if self .ota_base_station_id is None else self .ota_base_station_id
170162
171163 # Send a REQ (request) message through the OTA device
172164 # Next cycle we will hopefully have a CON (connected) response
173- self .ota .send_ota_message (
174- self .ota_base_station_id , "REQ"
175- ) # bUE sends a message back to the base station asking to
165+ self .ota .send_ota_message (self .ota_base_station_id , "REQ" ) # bUE sends a message back to the base station asking to
176166 # be connected as well
177167 print ("Sending a REQ" )
178168
@@ -187,9 +177,7 @@ def ota_idle_ping(self):
187177 print ("Getting GPS Data" )
188178 lat , long = self .gps_handler ()
189179 print ("trying to send a ping" )
190- self .ota .send_ota_message (
191- self .ota_base_station_id , f"PING,{ lat } ,{ long } "
192- ) # test ping for now
180+ self .ota .send_ota_message (self .ota_base_station_id , f"PING,{ lat } ,{ long } " ) # test ping for now
193181
194182 # See if there are any new messages from the OTA device
195183 try :
@@ -215,9 +203,7 @@ def ota_idle_ping(self):
215203 self .ota_timeout = TIMEOUT
216204 got_pingr = True
217205
218- elif (
219- "TEST" in message
220- ): # Message should look like 1,34,TEST.<file>.<configuration>.<role>.<starttime>,-1,8
206+ elif "TEST" in message : # Message should look like 1,34,TEST.<file>.<configuration>.<role>.<starttime>,-1,8
221207 input = parts [2 ]
222208
223209 self .test_handler (input )
@@ -236,13 +222,9 @@ def ota_idle_ping(self):
236222 self .ota_timeout -= 1
237223
238224 if self .ota_timeout <= TIMEOUT / 2 :
239- logger .info (
240- f"We haven't heard from { self .ota_base_station_id } in a while...."
241- )
225+ logger .info (f"We haven't heard from { self .ota_base_station_id } in a while...." )
242226 if self .ota_timeout <= 0 :
243- logger .info (
244- f"We have not heard from { self .ota_base_station_id } in too long. Disconnecting..."
245- )
227+ logger .info (f"We have not heard from { self .ota_base_station_id } in too long. Disconnecting..." )
246228 self .ota_connected = False
247229
248230 """
@@ -284,9 +266,7 @@ def ota_idle_ping(self):
284266 # logger.error(f"GPS error: {e}") # logger.debug("Could not find coordinates. Are they off?")
285267 # return "", ""
286268
287- def gps_handler (
288- self , max_attempts = 50 , min_fixes = 3 , hdop_threshold = 2.0 , max_runtime = 10
289- ):
269+ def gps_handler (self , max_attempts = 50 , min_fixes = 3 , hdop_threshold = 2.0 , max_runtime = 10 ):
290270 start_time = time .time ()
291271 try :
292272 session = gps .gps (mode = gps .WATCH_ENABLE | gps .WATCH_NEWSTYLE )
@@ -310,9 +290,7 @@ def gps_handler(
310290 eph = getattr (report , "eph" , None )
311291
312292 if lat is not None and lon is not None :
313- logger .debug (
314- f"Got GPS fix: lat={ lat } , lon={ lon } , HDOP={ eph } "
315- )
293+ logger .debug (f"Got GPS fix: lat={ lat } , lon={ lon } , HDOP={ eph } " )
316294 all_fixes .append ((lat , lon ))
317295 else :
318296 logger .debug ("GPS fix missing lat/lon fields" )
@@ -352,9 +330,7 @@ def test_handler(self, input): # Input Format: TEST-<file>-<wait_time>-<paramet
352330 current_time = int (time .time ())
353331 if start_time > current_time :
354332 wait_duration = start_time - current_time
355- logger .info (
356- f"Waiting { wait_duration } seconds until start time { start_time } "
357- )
333+ logger .info (f"Waiting { wait_duration } seconds until start time { start_time } " )
358334
359335 # Wait in small increments to allow for cancellation
360336 while int (time .time ()) < start_time and not self .cancel_test :
@@ -382,9 +358,7 @@ def test_handler(self, input): # Input Format: TEST-<file>-<wait_time>-<paramet
382358 text = True , # decode bytes to str
383359 )
384360
385- logger .info (
386- f"Started test script: { file } .py with parameters { parameters } "
387- )
361+ logger .info (f"Started test script: { file } .py with parameters { parameters } " )
388362
389363 def reader_thread (pipe , output_queue ):
390364 for line in iter (pipe .readline , "" ):
@@ -413,9 +387,7 @@ def reader_thread(pipe, output_queue):
413387
414388 # We also collect all the terminal outputs from the script so we can send them back to the base station
415389 """
416- while (
417- process .poll () is None
418- ): # poll() returns None if process hasn't terminated
390+ while process .poll () is None : # poll() returns None if process hasn't terminated
419391 # Get all normal terminal outputs
420392 try :
421393 stdout_line = stdout_queue .get_nowait ()
@@ -514,22 +486,14 @@ def ota_send_upd(self):
514486 with self .test_output_lock :
515487 if self .test_output_buffer :
516488 for line in self .test_output_buffer :
517- self .ota .send_ota_message (
518- self .ota_base_station_id , f"UPD:,{ lat } ,{ long } ,{ line } "
519- )
520- logger .info (
521- f"Sent UPD to { self .ota_base_station_id } with console output: { line } "
522- )
489+ self .ota .send_ota_message (self .ota_base_station_id , f"UPD:,{ lat } ,{ long } ,{ line } " )
490+ logger .info (f"Sent UPD to { self .ota_base_station_id } with console output: { line } " )
523491 time .sleep (0.4 ) # Sleep so UART does not get overwhelmed
524492 self .test_output_buffer .clear ()
525493
526494 else : # If there is no message send it blank
527- self .ota .send_ota_message (
528- self .ota_base_station_id , f"UPD:,{ lat } ,{ long } ,"
529- )
530- logger .info (
531- f"Sent UPD to { self .ota_base_station_id } with no console output"
532- )
495+ self .ota .send_ota_message (self .ota_base_station_id , f"UPD:,{ lat } ,{ long } ," )
496+ logger .info (f"Sent UPD to { self .ota_base_station_id } with no console output" )
533497
534498 """
535499 # This function checks for incoming messages while in the system is the UTW_TEST state.
@@ -553,9 +517,7 @@ def check_for_cancel(self):
553517 logger .info (f"Received a RESTART message" )
554518 self .restart_system ()
555519 else :
556- logger .error (
557- f"Received unexpected message while in UTW_TEST state: { message } "
558- )
520+ logger .error (f"Received unexpected message while in UTW_TEST state: { message } " )
559521
560522 """
561523 Restarts the service entirely
@@ -581,9 +543,7 @@ def restart_system(self):
581543
582544 def state_change_logger (self ):
583545 if self .cur_st != self .prv_st :
584- logger .info (
585- f"state_change_logger: State changed from { self .prv_st .name } to { self .cur_st .name } "
586- )
546+ logger .info (f"state_change_logger: State changed from { self .prv_st .name } to { self .cur_st .name } " )
587547 self .prv_st = self .cur_st
588548
589549 def bue_tick (self , loop_dur = 0.01 ):
0 commit comments