port as arg

This commit is contained in:
modelec
2025-05-06 22:10:15 +02:00
parent 5270e887a6
commit 698b420e6f
2 changed files with 20 additions and 8 deletions

View File

@@ -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
# socat -d -d pty,raw,echo=0 pty,raw,echo=0

View File

@@ -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")