From 698b420e6f7822da366999a3803144fd066ce816 Mon Sep 17 00:00:00 2001 From: modelec Date: Tue, 6 May 2025 22:10:15 +0200 Subject: [PATCH] port as arg --- simulated_pcb/alim.py | 15 ++++++++++----- simulated_pcb/odo.py | 13 ++++++++++--- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/simulated_pcb/alim.py b/simulated_pcb/alim.py index 8776df3..e78991c 100644 --- a/simulated_pcb/alim.py +++ b/simulated_pcb/alim.py @@ -2,12 +2,17 @@ import time import serial +import argparse -# Set the parameters for the serial connection -serial_port = '/dev/pts/11' # Modify this to your serial port (e.g., 'COM3' on Windows) -baud_rate = 115200 # Modify this to your baud rate -# Open the serial connection + +parser = argparse.ArgumentParser(description="Simulated PCB") +parser.add_argument('--port', type=str, default='/dev/pts/6', help='Serial port to use') +args = parser.parse_args() + +serial_port = args.port +baud_rate = 115200 + ser = serial.Serial(serial_port, baud_rate, timeout=1) try: @@ -26,4 +31,4 @@ finally: # Close the serial connection ser.close() -# socat -d -d pty,raw,echo=0 pty,raw,echo=0 \ No newline at end of file +# socat -d -d pty,raw,echo=0 pty,raw,echo=0 diff --git a/simulated_pcb/odo.py b/simulated_pcb/odo.py index 639d43c..77e15d9 100644 --- a/simulated_pcb/odo.py +++ b/simulated_pcb/odo.py @@ -2,9 +2,10 @@ import time import math import threading +import argparse class SimulatedPCB: - def __init__(self, port='/dev/pts/9', baud=115200): + def __init__(self, port='/dev/pts/6', baud=115200): self.ser = serial.Serial(port, baud, timeout=1) self.running = True self.start = False @@ -145,8 +146,14 @@ class SimulatedPCB: if __name__ == '__main__': + parser = argparse.ArgumentParser(description="Simulated PCB") + parser.add_argument('--port', type=str, default='/dev/pts/6', help='Serial port to use') + args = parser.parse_args() + + sim = None try: - sim = SimulatedPCB() + sim = SimulatedPCB(port=args.port) except KeyboardInterrupt: - sim.stop() + if sim: + sim.stop() print("Simulation stopped")