mirror of
https://github.com/modelec/modelec-marcel-ROS.git
synced 2026-01-18 16:47:43 +01:00
port as arg
This commit is contained in:
@@ -2,12 +2,17 @@
|
|||||||
import time
|
import time
|
||||||
|
|
||||||
import serial
|
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)
|
ser = serial.Serial(serial_port, baud_rate, timeout=1)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@@ -26,4 +31,4 @@ finally:
|
|||||||
# Close the serial connection
|
# Close the serial connection
|
||||||
ser.close()
|
ser.close()
|
||||||
|
|
||||||
# socat -d -d pty,raw,echo=0 pty,raw,echo=0
|
# socat -d -d pty,raw,echo=0 pty,raw,echo=0
|
||||||
|
|||||||
@@ -2,9 +2,10 @@
|
|||||||
import time
|
import time
|
||||||
import math
|
import math
|
||||||
import threading
|
import threading
|
||||||
|
import argparse
|
||||||
|
|
||||||
class SimulatedPCB:
|
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.ser = serial.Serial(port, baud, timeout=1)
|
||||||
self.running = True
|
self.running = True
|
||||||
self.start = False
|
self.start = False
|
||||||
@@ -145,8 +146,14 @@ class SimulatedPCB:
|
|||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
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:
|
try:
|
||||||
sim = SimulatedPCB()
|
sim = SimulatedPCB(port=args.port)
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
sim.stop()
|
if sim:
|
||||||
|
sim.stop()
|
||||||
print("Simulation stopped")
|
print("Simulation stopped")
|
||||||
|
|||||||
Reference in New Issue
Block a user