summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2022-02-14 11:47:36 +0100
committerHampusM <hampus@hampusmat.com>2022-02-14 11:47:36 +0100
commitcb7a167c7dee2fa1a19bd09ede3bae8b140e79da (patch)
tree3bc9443f0d988273a78f4654030ab65b3c580509 /tools
parent7892ef9d248c189be68ce7faf63230ec0a318b67 (diff)
build: use PlatformIO
Diffstat (limited to 'tools')
-rw-r--r--tools/monitor.py44
-rw-r--r--tools/reset.py73
-rw-r--r--tools/upload.sh12
3 files changed, 0 insertions, 129 deletions
diff --git a/tools/monitor.py b/tools/monitor.py
deleted file mode 100644
index f909efb..0000000
--- a/tools/monitor.py
+++ /dev/null
@@ -1,44 +0,0 @@
-"""Serial monitor."""
-import argparse
-import sys
-import asyncio
-import os
-
-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)
- )
-
-
-async def read(port: str, baud_rate: int):
- """Reads a serial port."""
- with Serial(port, baud_rate) as serial_port:
- while(serial_port.is_open):
- sys.stdout.buffer.write(serial_port.read())
- sys.stdout.flush()
-
-
-async def main():
- """Monitors serial output."""
- parser = argparse.ArgumentParser(
- description="A tool for monitoring a Arduino")
-
- parser.add_argument(
- "port", help="A serial device port e.g. /dev/ttyACM0 or com3")
- parser.add_argument("baud_rate", help="The serial device baud rate")
-
- args = parser.parse_args()
-
- await read(args.port, args.baud_rate)
-
-if __name__ == "__main__":
- try:
- asyncio.run(main())
- except KeyboardInterrupt:
- print("\nReceived keyboard interrupt. Exiting...")
- exit(0)
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])
diff --git a/tools/upload.sh b/tools/upload.sh
deleted file mode 100644
index eddf4de..0000000
--- a/tools/upload.sh
+++ /dev/null
@@ -1,12 +0,0 @@
-#!/bin/bash
-
-DEVICE_PATH=$1
-PYTHON_CMD=$2
-AVRDUDE=$3
-AVRDUDE_COM_OPTS=$4
-AVRDUDE_ARD_OPTS=$5
-AVRDUDE_UPLOAD_HEX=$6
-
-new_port=$($PYTHON_CMD ./tools/reset.py $DEVICE_PATH 2> /dev/tty)
-
-$AVRDUDE $AVRDUDE_COM_OPTS $AVRDUDE_ARD_OPTS $new_port $AVRDUDE_UPLOAD_HEX