gtjoseph / mt3339-utils

MIT License
62 stars 21 forks source link

gpsstatus _curses.error: curses function returned NULL #12

Closed dzfranklin closed 2 years ago

dzfranklin commented 2 years ago
> ./gpstatus  /dev/serial/by-id/usb-Signoid_Kft._USB-UART_adapter_MDWCJX-if00-port0
Traceback (most recent call last):
  File "/home/daniel/mt3339-utils/./gpsstatus", line 535, in <module>
    rc = curses.wrapper(main)
  File "/usr/lib/python3.10/curses/__init__.py", line 94, in wrapper
    return func(stdscr, *args, **kwds)
  File "/home/daniel/mt3339-utils/./gpsstatus", line 518, in main
    init_windows()
  File "/home/daniel/mt3339-utils/./gpsstatus", line 222, in init_windows
    draw_string(s['STATUS'], 0, 15, "Device: %s" % gps_device)
  File "/home/daniel/mt3339-utils/./gpsstatus", line 106, in draw_string
    dw = win.derwin(1, erase, row, col)
_curses.error: curses function returned NULL

This is caused by the device name being to long. I didn't know the normal way to refer to a device would be something like /dev/ttyUSB0.

I don't think this is worth fixing. I'm filing and immediately closing this issue in the hope this will save someone else what for me was an embarrassing amount of debugging.

gtjoseph commented 2 years ago

The /dev/serial/... name is actually good because it'll be constant for a specific device no matter when or where it's plugged in but it is long. Another way is to create a udev rule that creates a constant symlink in /dev like so...

/etc/udev/rules.d/50-gps.rules

SUBSYSTEM=="tty", ATTRS{serial}=="UBXF9P01", MODE="0666", SYMLINK+="ttyUSB_UBF9001"

That would make a USB device with serial number UBXF9P01 always show up as /dev/ttyUSB_UBF9001 no matter where or when it's plugged in. Could also make the name /dev/gps-UBF9001 or anything that's convenient to you.

Anyway, I'll at least see if I can test the file name length and if it doesn't fit, maybe use the /dev/ttyUSB... symlink or just truncate the name to fit. Thanks for the report.