Skip to content

Commit 5a1b8fb

Browse files
committed
Final code with exiting issue resolved for both Arduino Uno R3 & R4 and also resolve the issue of argparser abbrevations.
1 parent f4649b8 commit 5a1b8fb

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

chords.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -328,8 +328,11 @@ def cleanup():
328328
if ser is not None and ser.is_open:
329329
print("Sending STOP to Arduino and closing serial port.")
330330
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.")
333336
ser.close() # Close the serial port
334337
print("Serial connection closed.")
335338
else:
@@ -373,7 +376,7 @@ def signal_handler(sig, frame):
373376
# Main entry point of the script
374377
def main():
375378
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
377380
parser.add_argument('-p', '--port', type=str, help="Specify the COM port") # Port argument
378381
parser.add_argument('-b', '--baudrate', type=int, default=230400, help="Set baud rate for the serial communication") # Baud rate
379382
parser.add_argument('--csv', action='store_true', help="Create and write to a CSV file") # CSV logging flag

0 commit comments

Comments
 (0)