import serial
import subprocess
def execute_shell_file(file_path):
try:
subprocess.run(["bash", file_path], check=True)
except subprocess.CalledProcessError as e:
print(f"Error executing the shell file: {e}")
def main():
# 串口配置,根据实际情况修改
serial_port = "/dev/ttyTHS1" # 根据实际串口名称修改
baud_rate = 9600 # 根据实际波特率修改
# 打开串口
try:
ser = serial.Serial(serial_port, baud_rate, timeout=1)
print(f"Serial port {serial_port} opened successfully.")
except Exception as e:
print(f"Error opening the serial port: {e}")
return