firmware icon indicating copy to clipboard operation
firmware copied to clipboard

[Feature Request]: CH341 USB device scanning (auto-enumeration)

Open vidplace7 opened this issue 1 year ago • 4 comments

Platform

Linux Native

Description

Currently meshtasticd requires manual config file changes after installation, which can be daunting to users who are not experienced with Linux. With the coming release of CH341 USB dongles, we have the opportunity to provide a more simplified out of box experience.

meshtasticd should probe the usb bus for devices that match known VID and PID values, and select the appropriate pinmap if a known VID:PID value can be found.

This should become the default configuration of meshtasticd, while still allowing advanced users to change their configs for SPI Pi Hats / etc.

vidplace7 avatar Jan 12 '25 15:01 vidplace7

@psiegl would you consider taking a look at this? :heart:

vidplace7 avatar Jan 12 '25 15:01 vidplace7

Well, what can I say: You are truly right. It took me quite some afternoons to gdb myself through the code, figuring out what's going on. And I see your concern, meaning it is though to set up the right config. E.g. https://github.com/meshtastic/firmware/blob/master/src/platform/portduino/PortduinoGlue.cpp#L532 . Imagine you are missing the General: part in your homebrew config. Suddenly, meshtastic doesn't have the default general config flags, and well it doesn't survive and won't tell you :) . Just one of the issues, I stumbled into. My first thought was to propose a general config, that Meshtastic always comes with, while the user can 'overlay' his/her. However, you are right: Ideally meshtastic tries at least its best to scan for known configs and solely relies on the user interaction in case he/she enforces it. I will for sure propose changes to the PortduinoGlue.cpp. Maybe I have a good idea, how to bring in your idea.

psiegl avatar Jan 12 '25 16:01 psiegl

Can't this be done automatically using udev rules (assuming with coming release you mean those with a unique serial number stored in eeprom) ? E.g. something like:

SUBSYSTEM=="usb", ACTION=="add" ATTRS{idVendor}=="1a86", ATTRS{idProduct}=="5512", DRIVERS=="ch341", PROGRAM="/usr/sbin/meshtastic-macgen %n" RUN+="/usr/sbin/meshtasticd -h %c -d ${HOME}/.portduino/%c -c /etc/meshtasticd/config-%n.yaml" MODE:="0666", ENV{ID_MM_DEVICE_IGNORE}="1", ENV{ID_MM_PORT_IGNORE}="1"

I.e. when you plugin a CH341 device a new meshtasticd process is automatically launched with the matching config.yaml file.

mverch67 avatar Jan 13 '25 07:01 mverch67

I believe that's a good idea. The package could install a file in /etc/udev/rules.d/

fifieldt avatar Jan 13 '25 08:01 fifieldt