From cb7a167c7dee2fa1a19bd09ede3bae8b140e79da Mon Sep 17 00:00:00 2001 From: HampusM Date: Mon, 14 Feb 2022 11:47:36 +0100 Subject: build: use PlatformIO --- tools/reset.py | 73 ---------------------------------------------------------- 1 file changed, 73 deletions(-) delete mode 100644 tools/reset.py (limited to 'tools/reset.py') diff --git a/tools/reset.py b/tools/reset.py deleted file mode 100644 index 6398c50..0000000 --- a/tools/reset.py +++ /dev/null @@ -1,73 +0,0 @@ -"""A tool to reset a Arduino.""" -import os -import sys -from typing import List -import argparse -from time import sleep - -import serial.tools.list_ports -from serial.tools.list_ports_common import ListPortInfo - - -if os.name == "nt": # NT-based operating systems (Windows) - from serial.serialwin32 import Serial -elif os.name == "posix": - from serial.serialposix import Serial -else: - raise NotImplementedError( - "Sorry no implementation for your platform ({}) available." - .format(sys.platform) - ) - - -def get_ports(): - """Returns a list of serial ports attached.""" - serial_ports = serial.tools.list_ports.comports() - - return [port.device for port in serial_ports] - - -def compare_ports( - avail_ports: List[str], - wanted_ports: List[str] -): - return [port for port in avail_ports if port in wanted_ports] - - -class ParsedArguments: - """Parsed command-line arguments.""" - port: str - - -if __name__ == "__main__": - parser = argparse.ArgumentParser(description='Reset an Arduino') - - parser.add_argument('port', help='Serial device e.g. /dev/ttyACM0 or com3') - - args = parser.parse_args(namespace=ParsedArguments) - - ports: List[str] = [] - - while args.port not in ports: - ports = get_ports() - - sys.stderr.write( - f"PORTS {{{', '.join(ports)}}} / {{{args.port}}} " - f"=> {{{', '.join(compare_ports(ports, [args.port]))}}}\n" - ) - sys.stderr.flush() - - sleep(0.5) - - ser = Serial(args.port, 57600) - - ser.baudrate = 1200 - - # ser.setRTS(True) - # ser.setDTR(False) - - ser.close() - - sleep(2) - - print(get_ports()[0]) -- cgit v1.2.3-18-g5258