Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: improve serial port handling #915

Merged
merged 3 commits into from Jan 5, 2020
Merged

Conversation

tkurki
Copy link
Member

@tkurki tkurki commented Dec 17, 2019

Fix the dead stupid serial port selection UI:

  • add Enter manually selection to the popup menu
  • the text field is enabled only when the user has chosen manual entry
  • manual entry is implicitly chosen if the serial port listing retrieved from the server does not contain the path saved in the configuration

List serial ports using four methods:
- /dev/serial/by-id
- /dev/serial/by-path
- /dev/ttyOP_*
- using serialport module

OpenPlotter 2 has a serial port manager that allows the user to rename serial ports with symbolic names using udev rules. On Linux there are already persistent names under by-id and lastly serialport works on at least MacOS and hopefully on Windows as well.

Fixes #880 .

Add 'Enter manually' as an item into the popup menu. If that is the
chosen option the text field is enabled. If the user chooses a serial
port from the list the text field is disabled and the configuration
will be updated with the value from the list.
List serial ports using three methods:
- /dev/serial/by-id
- /dev/ttyOP_*
- using serialport module

OpenPlotter 2 has a serial port manager that allows the user to
rename serial ports with symbolic names using udev rules. On Linux
there are already persistent names unde by-id and lastly serialport
works on at least MacOS and hopefully on Windows as well.
@tkurki
Copy link
Member Author

tkurki commented Dec 17, 2019

@sailoog do you have time to try this out?

git clone https://github.com/SignalK/signalk-server-node.git &&\
git checkout fix-serial-port-selection
cd signalk-server-node &&\
npm install &&\
pushd packages/server-admin-ui/ &&\
npm install &&\
npm run build &&\
npm link &&\
popd  &&\
npm link @signalk/server-admin-ui &&\
bin/signalk-server

@sailoog
Copy link
Contributor

sailoog commented Dec 17, 2019

Not until Thursday, sorry :(

@e-sailing
Copy link
Contributor

Now the symbolic names show up. Thanks.
(
"/dev/serial/by-id" does work on many serial usb converter but not on ch340.
I connected 3 * ch340 and they are shown as ttyUSB0, ttyUSB1, ttyUSB2 but only one is shown by-id (they all have the same id).
)

@tkurki
Copy link
Member Author

tkurki commented Dec 18, 2019

Yes, it is less than perfect but for many cases by-id works ok (I'd imagine most systems have just a few, different serial devices) and is something that works better than serialport provided paths in systems without OpenPlotter.

@e-sailing how do these devices show up at /dev/serial/by-path/ ?

We could also change the UI so that the three different methods would be clearer to the end user.

@e-sailing
Copy link
Contributor

Devices show up:
pi@openplotter:~ $ ls /dev/serial/by-id/
usb-1a86_USB2.0-Serial-if00-port0
pi@openplotter:~ $ lsusb
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 002: ID 152d:0579 JMicron Technology Corp. / JMicron USA Technology Corp.
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 004: ID 148f:5370 Ralink Technology, Corp. RT5370 Wireless Adapter
Bus 001 Device 021: ID 1a86:7523 QinHeng Electronics HL-340 USB-Serial adapter
Bus 001 Device 016: ID 1a86:7523 QinHeng Electronics HL-340 USB-Serial adapter
Bus 001 Device 022: ID 1a86:7523 QinHeng Electronics HL-340 USB-Serial adapter
Bus 001 Device 003: ID 2001:f103 D-Link Corp. DUB-H7 7-port USB 2.0 hub
Bus 001 Device 002: ID 2109:3431 VIA Labs, Inc. Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
pi@openplotter:~ $ ls /dev/serial/by-id/
usb-1a86_USB2.0-Serial-if00-port0
pi@openplotter:~ $ ls /dev/ttyU*
/dev/ttyUSB0 /dev/ttyUSB1 /dev/ttyUSB2
pi@openplotter:~ $ ls /dev/serial/by-path
platform-fd500000.pcie-pci-0000:01:00.0-usb-0:1.2.1:1.0-port0 platform-fd500000.pcie-pci-0000:01:00.0-usb-0:1.2.2:1.0-port0 platform-fd500000.pcie-pci-0000:01:00.0-usb-0:1.2.6:1.0-port0

Yes. If you use by-path it will work.
Everyone has to keep in mind that he shouldn't connect the usb cable to a different port.
(To connect nmea 0183 RS422 devices to the raspberry or pc you have up to 6 identical usb rs422 ch340 converter!)

We could also change the UI so that the three different methods would be clearer to the end user.

Yes.
4 dropdown menus:
1 standard tty name (not recommended)
2 by-id
3 by-path
4 by symbolic link (udev (openplotter))
or 2 dropdown menu
a) select one of the 4 views
b) select the device in the list of the selected view

Change payload to contain lists of serialports for
the different listing methods and show them in the
popup menu  with separators.
@tkurki
Copy link
Member Author

tkurki commented Dec 23, 2019

@e-sailing I pushed a new version that uses just one menu, but with separators to tell the paths produced by the different methods apart.

@tkurki
Copy link
Member Author

tkurki commented Dec 25, 2019

Fixes #880.

@tkurki tkurki merged commit 9702b76 into master Jan 5, 2020
@tkurki tkurki deleted the fix-serial-port-selection branch January 5, 2020 09:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for by-id serial device paths
3 participants