Skip to content

Commit

Permalink
Made list_uart_device_paths more verbose
Browse files Browse the repository at this point in the history
  • Loading branch information
ywh114 committed Feb 25, 2024
1 parent c423e92 commit 73b1145
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions Communication/communicator.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,18 +279,20 @@ def list_uart_device_paths():
OSX prefix: "tty.usbmodem"
Jetson / Linux prefix: "ttyUSB", "ttyACM"
Linux: look under "/dev/serial/by-id": "usb-STMicroelectronics_STM32_STLink_"
Returns:
[Maybe dev_path] : a list of possible device paths
"""
# list of possible prefixes
UART_PREFIX_LIST = ("tty.usbmodem", "ttyUSB", "ttyACM")
dev_list = os.listdir("/dev")
UART_PREFIX_LIST = ('tty.usbmodem', 'usb-STMicroelectronics_STM32_STLink_')
dev_basename = '/dev/serial/by-id'
dev_list = os.listdir(dev_basename)

dev_paths = [] # ret val
for dev_name in dev_list:
if dev_name.startswith(UART_PREFIX_LIST):
dev_paths += [os.path.join('/dev', dev_name)]
dev_paths += [os.path.join(dev_basename, dev_name)]
return dev_paths or [None]

# path -> [path] -> Maybe serial.Serial
Expand Down
2 changes: 1 addition & 1 deletion minipc-tmux-daemon-helper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ function clean() {
if [ ! -f "${script_log}" ]; then
echo "${script_log}" does not exist.
echo Nothing to be cleaned.
[ "${reinstall}" ] \
[ ${reinstall} ] \
&& return 0 \
|| exit 0
fi
Expand Down

0 comments on commit 73b1145

Please sign in to comment.