python icon indicating copy to clipboard operation
python copied to clipboard

Serial on FreeBSD (/dev/ttyU0)

Open paigeadelethompson opened this issue 6 months ago • 1 comments

Hey, I decided to give this a shot on FreeBSD, it almost seems like it wants to work:

ugen0.3: <Espressif Systems BQ Station G2> at usbus0 (disconnected)
umodem0: at uhub0, port 2, addr 6 (disconnected)
umodem0: detached
ugen0.3: <Espressif Systems BQ Station G2> at usbus0
umodem0 on uhub0
umodem0: <Espressif Systems BQ Station G2, class 239/2, rev 2.00/1.00, addr 7> on usbus0
umodem0: data interface 1, has no CM over data, has no break

though it doesn't do anything:

➜  sq meshtastic --debug --port /dev/ttyU0
DEBUG file:__main__.py common line:1272 Not logging serial output
DEBUG file:serial_interface.py __init__ line:47 Connecting to /dev/ttyU0

So I started looking at the code for it and noticed the termios / tcsetattr and it dawned on me that it probably has something to do with that because I've had to use different termios settings for FreeBSD before. I noticed there's some tcsetattr stuff here for Windows specifically:

https://github.com/meshtastic/python/blob/master/meshtastic/serial_interface.py#L51

from the pyserial project:

The module named "serial" automatically selects the appropriate backend.

yeah evidently not if you're having to use tcsetattr :) but yeah I'm at a loss for what backend it might be trying to use:

self.stream = serial.Serial(
            self.devPath, 115200, exclusive=True, timeout=0.5, write_timeout=0
        )

since we don't really get anymore log messages after

        logging.debug(f"Connecting to {self.devPath}")

I'll take a look at this a bit later but just in case I forget, here's a ticket

paigeadelethompson avatar Jun 25 '25 00:06 paigeadelethompson

Oh one more thing I can confirm that the serial port can be opened with screen /dev/ttyU0 and it just gives you the serial log:

DEBUG | ??:??:?? 8 [Screen] haveGlyphs=1
INFO  | ??:??:?? 9 [PowerFSM] Init the NimBLE bluetooth module
DEBUG | ??:??:?? 9 [Screen] haveGlyphs=1
DEBUG | ??:??:?? 10 [Screen] haveGlyphs=1
INFO  | ??:??:?? 11 [Screen] Done with boot screen
DEBUG | ??:??:?? 11 [Screen] Show standard frames
DEBUG | ??:??:?? 11 [Screen] Show 0 module frames

So I would guess this is just an issue with how to do CTS/RTS on FreeBSD maybe

paigeadelethompson avatar Jun 25 '25 01:06 paigeadelethompson