proxyclient:m1n1:add macOS device name for m1n1 primary UART

m1n1 UART device names on macOS follow /dev/cu.usbmodemP_XX naming
convention. Check for platform name using platform.system() and use the
macOS device name instead of /dev/m1n1 if equals 'Darwin'

Signed-off-by: Alexis Deruelle <alexis.deruelle@gmail.com>
This commit is contained in:
Alexis Deruelle 2022-11-12 14:42:11 +01:00 committed by Hector Martin
parent 6bca5f77e1
commit bd82c5f47a

View file

@ -1,5 +1,5 @@
# SPDX-License-Identifier: MIT
import os, sys, struct, serial, time
import platform, os, sys, struct, serial, time
from construct import *
from enum import IntEnum, IntFlag
from serial.tools.miniterm import Miniterm
@ -131,13 +131,18 @@ class UartInterface(Reloadable):
REPLY_LEN = 36
EVENT_HDR_LEN = 8
DEFAULT_UART_DEV="/dev/m1n1"
DEFAULT_BAUD_RATE=115200
if platform.system() == 'Darwin':
DEFAULT_UART_DEV="/dev/cu.usbmodemP_01"
def __init__(self, device=None, debug=False):
self.debug = debug
self.devpath = None
if device is None:
device = os.environ.get("M1N1DEVICE", "/dev/m1n1:115200")
device = os.environ.get("M1N1DEVICE", self.DEFAULT_UART_DEV)
if isinstance(device, str):
baud = 115200
baud = self.DEFAULT_BAUD_RATE
if ":" in device:
device, baud = device.rsplit(":", 1)
baud = int(baud)