Compare commits

..

2 Commits

Author SHA1 Message Date
dw-0
c4ba133a9d Merge 0adbf8be49 into 2e6c66e524 2024-10-03 13:58:45 +02:00
dw-0
0adbf8be49 fix: correctly find connected USB DFU devices
Signed-off-by: Dominik Willner <th33xitus@gmail.com>
2024-10-03 09:42:10 +02:00

View File

@@ -6,7 +6,7 @@
# #
# This file may be distributed under the terms of the GNU GPLv3 license #
# ======================================================================= #
import re
from subprocess import (
DEVNULL,
PIPE,
@@ -50,8 +50,8 @@ def find_firmware_file() -> bool:
def find_usb_device_by_id() -> List[str]:
try:
command = "find /dev/serial/by-id/*"
output = check_output(command, shell=True, text=True, stderr=DEVNULL)
command = "find /dev/serial/by-id/* 2>/dev/null"
output = check_output(command, shell=True, text=True)
return output.splitlines()
except CalledProcessError as e:
Logger.print_error("Unable to find a USB device!")
@@ -61,14 +61,9 @@ def find_usb_device_by_id() -> List[str]:
def find_uart_device() -> List[str]:
try:
cmd = "find /dev -maxdepth 1"
output = check_output(cmd, shell=True, text=True, stderr=DEVNULL)
device_list = []
if output:
pattern = r"^/dev/tty(AMA0|S0)$"
devices = output.splitlines()
device_list = [d for d in devices if re.search(pattern, d)]
return device_list
command = '"find /dev -maxdepth 1 -regextype posix-extended -regex "^\/dev\/tty(AMA0|S0)$" 2>/dev/null"'
output = check_output(command, shell=True, text=True)
return output.splitlines()
except CalledProcessError as e:
Logger.print_error("Unable to find a UART device!")
Logger.print_error(e, prefix=False)