import serial
import time
import sys

if len(sys.argv) != 2:
    print("Usage: python set_rts.py <COM port>")
    print("Example: python set_rts.py COM20")
    sys.exit(1)

com_port = sys.argv[1]

try:
    ser = serial.Serial(
        port=com_port,
        baudrate=115200,
        timeout=1,
        rtscts=False
    )

    ser.setRTS(False)
    print(f"{com_port}: RTS pull low.")

    ser.close()

except serial.SerialException as e:
    print(f"Failed to open {com_port}：{e}")
    sys.exit(2)

