30 lines
1.0 KiB
Python
30 lines
1.0 KiB
Python
|
|
import serial
|
||
|
|
import time
|
||
|
|
|
||
|
|
# Serial Port Configuration
|
||
|
|
port = '/dev/ttyUSB0' # Replace with your actual serial port (e.g., 'COM3' on Windows)
|
||
|
|
baudrate = 57600 # Replace with your desired baud rate
|
||
|
|
timeout = 1 # Optional timeout for read operations (in seconds)
|
||
|
|
|
||
|
|
NUM_CYCLES = 100000
|
||
|
|
|
||
|
|
# Serial Connection Setup
|
||
|
|
try:
|
||
|
|
ser = serial.Serial(port, baudrate, timeout=timeout)
|
||
|
|
print(f"Connected to serial port: {port}")
|
||
|
|
|
||
|
|
ser.write("fts arm\n".encode()) # Encode string to bytes for transmission
|
||
|
|
print(f"Sent ARM")
|
||
|
|
|
||
|
|
cnt = 0
|
||
|
|
while cnt < NUM_CYCLES:
|
||
|
|
ser.write("fts fire\n".encode()) # Encode string to bytes for transmission
|
||
|
|
print(f"Sent FIRE # {cnt}")
|
||
|
|
time.sleep(1) # Wait for 1 second
|
||
|
|
ser.write("fts reset\n".encode()) # Encode string to bytes for transmission
|
||
|
|
print(f"Sent RESET")
|
||
|
|
time.sleep(1) # Wait for 1 second
|
||
|
|
cnt+=1
|
||
|
|
print("----------TEST FINISHED----------")
|
||
|
|
except serial.SerialException as e:
|
||
|
|
print(f"Error opening serial port: {e}")
|