@@ -328,8 +328,11 @@ def cleanup():
328
328
if ser is not None and ser .is_open :
329
329
print ("Sending STOP to Arduino and closing serial port." )
330
330
send_command (ser , 'STOP' ) # Ensure the STOP command is sent
331
- ser .flushInput () # Clear the input buffer
332
- ser .flushOutput () # Clear the output buffer
331
+ time .sleep (1 )
332
+ ser .reset_input_buffer () # Clear the input buffer
333
+ print ("Input buffer cleared." )
334
+ ser .reset_output_buffer () # Clear the output buffer
335
+ print ("Output buffer cleared." )
333
336
ser .close () # Close the serial port
334
337
print ("Serial connection closed." )
335
338
else :
@@ -373,7 +376,7 @@ def signal_handler(sig, frame):
373
376
# Main entry point of the script
374
377
def main ():
375
378
global verbose ,ser
376
- parser = argparse .ArgumentParser (description = "Upside Down Labs - BioAmp Tool" ) # Create argument parser
379
+ parser = argparse .ArgumentParser (description = "Upside Down Labs - BioAmp Tool" , allow_abbrev = False ) # Create argument parser
377
380
parser .add_argument ('-p' , '--port' , type = str , help = "Specify the COM port" ) # Port argument
378
381
parser .add_argument ('-b' , '--baudrate' , type = int , default = 230400 , help = "Set baud rate for the serial communication" ) # Baud rate
379
382
parser .add_argument ('--csv' , action = 'store_true' , help = "Create and write to a CSV file" ) # CSV logging flag
0 commit comments