diff --git a/Devices/Console/Firmware/platformio.ini b/Devices/Console/Firmware/platformio.ini index 0351c8d..2c6a8d1 100644 --- a/Devices/Console/Firmware/platformio.ini +++ b/Devices/Console/Firmware/platformio.ini @@ -52,7 +52,7 @@ upload_flags = -v -V -D -upload_command = python switchDevice.py && avrdude $UPLOAD_FLAGS -U flash:w:$SOURCE:i +upload_command = python switchDevice.py ${env:Upload_UART_Forwarded.upload_port} && avrdude $UPLOAD_FLAGS -U flash:w:$SOURCE:i ; Run the following command to upload with this environment diff --git a/Devices/Console/Firmware/switchDevice.py b/Devices/Console/Firmware/switchDevice.py index 78375b4..1045297 100644 --- a/Devices/Console/Firmware/switchDevice.py +++ b/Devices/Console/Firmware/switchDevice.py @@ -1,6 +1,23 @@ import serial import time -ser = serial.Serial("COM5") -ser.write(b's') -ser.close() -time.sleep(1) \ No newline at end of file +import sys + +class bcolors: + HEADER = '\033[95m' + OKBLUE = '\033[94m' + OKCYAN = '\033[96m' + OKGREEN = '\033[92m' + WARNING = '\033[93m' + FAIL = '\033[91m' + ENDC = '\033[0m' + BOLD = '\033[1m' + UNDERLINE = '\033[4m' + +if len(sys.argv) == 1: + print(f"{bcolors.FAIL}Please enter COM Port as argument{bcolors.ENDC}") +else: + ser = serial.Serial(sys.argv[1]) + ser.write(b's') + ser.close() + print(f"{bcolors.OKGREEN}Forwarding activated{bcolors.ENDC}") + time.sleep(1) \ No newline at end of file diff --git a/Devices/Control/Firmware/enableReset.py b/Devices/Control/Firmware/enableReset.py index e4b9cde..bcd7bd2 100644 --- a/Devices/Control/Firmware/enableReset.py +++ b/Devices/Control/Firmware/enableReset.py @@ -1,6 +1,24 @@ import serial import time -ser = serial.Serial("COM5") -ser.write(b'r') -ser.close() -time.sleep(1) \ No newline at end of file +import sys + +class bcolors: + HEADER = '\033[95m' + OKBLUE = '\033[94m' + OKCYAN = '\033[96m' + OKGREEN = '\033[92m' + WARNING = '\033[93m' + FAIL = '\033[91m' + ENDC = '\033[0m' + BOLD = '\033[1m' + UNDERLINE = '\033[4m' + +if len(sys.argv) == 1: + print(f"{bcolors.FAIL}Please enter COM Port as argument{bcolors.ENDC}") + +else: + ser = serial.Serial(sys.argv[1]) + ser.write(b'r') + ser.close() + print(f"{bcolors.OKGREEN}Reset enabled{bcolors.ENDC}") + time.sleep(1) diff --git a/Devices/Control/Firmware/platformio.ini b/Devices/Control/Firmware/platformio.ini index 980567d..0cd4a5e 100644 --- a/Devices/Control/Firmware/platformio.ini +++ b/Devices/Control/Firmware/platformio.ini @@ -43,7 +43,7 @@ upload_flags = -v -V -D -upload_command = python enableReset.py && avrdude $UPLOAD_FLAGS -U flash:w:$SOURCE:i +upload_command = python enableReset.py ${env:Upload_UART.upload_port} && avrdude $UPLOAD_FLAGS -U flash:w:$SOURCE:i ; Run the following command to upload with this environment ; pio run -e Upload_ISP -t upload