# /// script # dependencies = ["pyserial>=3.5"] # /// import serial # This script uses the FW-1000-SA as an example def main() -> None: with serial.Serial("COM4", 115200, write_timeout=1, timeout=5) as serial_port: command = b"?" # no "\n\r" at the end serial_port.write(command) response = serial_port.read(size=1) # response is a single byte print(f"{command = }\n{response = }") command = b"HA\n\r" # requires "\n\r" at the end serial_port.write(command) response = serial_port.read_until(b">") print(f"{command = }\n{response = }") if __name__ == "__main__": main()