@@ -135,7 +135,7 @@ class Surveyor240(PingDevice):
135135 sync = file .read (2 )
136136 if sync != b'BR' :
137137 return None
138-
138+
139139 payload_len_bytes = file .read (2 )
140140 if len (payload_len_bytes ) < 2 :
141141 return None
@@ -161,7 +161,7 @@ class Surveyor240(PingDevice):
161161 protocol = "tcp"
162162 elif self .iodev .type == socket .SOCK_DGRAM :
163163 protocol = "udp"
164-
164+
165165 if self .server_address :
166166 url = f"{ protocol } ://{ self .server_address [0 ]} :{ self .server_address [1 ]} "
167167 else :
@@ -214,12 +214,12 @@ class Surveyor240(PingDevice):
214214 checksum = sum (msg_data ) & 0xFFFF
215215 msg_data += bytearray (struct .pack (pingmessage .PingMessage .endianess + pingmessage .PingMessage .checksum_format , checksum ))
216216
217- m .msg_data = msg_data
217+ m .msg_data = msg_data
218218 m .checksum = checksum
219219
220220 return m
221221
222- # Enable logging
222+ # Enable logging
223223 def start_logging (self , new_log = False , log_directory = None ):
224224 if self .logging :
225225 return
@@ -228,15 +228,15 @@ class Surveyor240(PingDevice):
228228
229229 if self .current_log is None or new_log :
230230 self .new_log (log_directory )
231-
231+
232232 def stop_logging (self ):
233233 self .logging = False
234234
235235 # Creates a new log file
236236 def new_log (self , log_directory = None ):
237237 dt = datetime .now ()
238238 save_name = dt .strftime ("%Y-%m-%d-%H-%M" )
239-
239+
240240 if log_directory is None :
241241 project_root = Path .cwd ().parent
242242 self .log_directory = project_root / "logs/surveyor"
@@ -249,7 +249,7 @@ class Surveyor240(PingDevice):
249249
250250 if log_path .exists ():
251251 log_path .unlink () # delete existing file (program was restarted quickly)
252-
252+
253253 self .current_log = log_path
254254 self .logging = True
255255 self .bytes_written = 0
@@ -262,7 +262,7 @@ class Surveyor240(PingDevice):
262262 def write_data (self , msg ):
263263 if not self .logging or not self .current_log :
264264 return
265-
265+
266266 try :
267267 if self .bytes_written > MAX_LOG_SIZE_MB * 1000000 :
268268 self .new_log (log_directory = self .log_directory )
@@ -291,9 +291,9 @@ class Surveyor240(PingDevice):
291291 self .write (response .msg_data )
292292
293293 return True
294-
294+
295295 return super ().handle_message (msg )
296-
296+
297297 # Override wait_message to also handle UTC requests from Surveyor and for creating atof_t data
298298 def wait_message (self , message_ids , timeout = 0.5 ):
299299 tstart = time .time ()
@@ -302,7 +302,7 @@ class Surveyor240(PingDevice):
302302 if msg is not None :
303303 if msg .message_id == definitions .SURVEYOR240_UTC_REQUEST :
304304 continue
305-
305+
306306 if msg .message_id == definitions .SURVEYOR240_ATOF_POINT_DATA :
307307 atof_byte_array = bytearray (msg .atof_point_data )
308308 formatted_atof_array = struct .unpack ('<' + 'I' * (4 * int (msg .num_points )), atof_byte_array )
@@ -324,7 +324,7 @@ class Surveyor240(PingDevice):
324324 def connect_tcp (self , host : str = None , port : int = 12345 , timeout : float = 5.0 ):
325325 if host is None :
326326 host = '0.0.0.0'
327-
327+
328328 self .server_address = (host , port )
329329 try :
330330 print ("Opening %s:%d" % self .server_address )
@@ -335,7 +335,7 @@ class Surveyor240(PingDevice):
335335
336336 except socket .timeout :
337337 print ("Unable to connect to device" )
338- raise Exception ("Connection timed out after {0} seconds" .format (timeout ))
338+ raise Exception ("Connection timed out after {0} seconds" .format (timeout ))
339339 except Exception as exception :
340340 raise Exception ("Failed to open the given TCP port: {0}" .format (exception ))
341341
@@ -365,9 +365,9 @@ class Surveyor240(PingDevice):
365365
366366 except BlockingIOError as exception :
367367 pass # Ignore exceptions related to read before connection, a result of UDP nature
368-
368+
369369 except ConnectionResetError as e :
370- raise ConnectionError ("Socket connection was reset: %s" % str (e ))
370+ raise ConnectionError ("Socket connection was reset: %s" % str (e ))
371371
372372 # Class to represent the atof_t struct
373373 class atof_t :
@@ -394,7 +394,7 @@ class Surveyor240(PingDevice):
394394
395395 atof = Surveyor240 .atof_t (angle , tof , reserved )
396396 atof_list .append (atof )
397-
397+
398398 return tuple (atof_list )
399399
400400 # Creates yz_point_data and fills it with the correct data from the message
0 commit comments