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

Serial Output Settings #281

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

xiaprojects
Copy link
Contributor

This PR will add more USB RS232 Dongles and Settings interface:
image

Copy link
Collaborator

@b3nn0 b3nn0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally very well done, thank you!
I do have some general caveat though, but not really a simple solution.. maybe you have an idea?

  • Currently, everything that is detected as ttyUSB* is offered, including GPSes that can not be used for serialout. In fact, it would break GPS functionality if someone accidentally selects it, because the serial port is opened twice. I think we have to filter those - people tend to configure all kind of random stuff without knowing what they are doing, then open issues when stuff doesn't work. I'd like to prevent that by design..
  • Right now, when I plug in my existing adapter, it will show up twice, once as /dev/serialout0 and once as /dev/ttyUSB0, which is confusing.. I think the USB0 should be filtered somehow (how? Maybe we can change the udev rule not not add a symlink, but instead rename the device alltogether?)
  • The main reason why I didn't implement this myself already: how to deal with changing device paths? /dev/ttyUSB0 might become /dev/ttyUSB1 and /dev/ttyUSB1 might become /dev/ttyUSB0. Just to change again on the next boot. Device paths in /dev are NOT predictable, unfortunately.
    The obvious solution would be to list /dev/serial/by-id/* instead.
    However, how do we deal with /dev/serialout0 vs /dev/serialout_nmea0 pre-configuration?

This is my suggestion...:

  • We screw backwards compatibility. serialout0/serialout_nmea0 pre-configuration is dropped alltogether. User must configure his serialout device via the web interface to get any output.
  • We drop all serialout udev rules
  • The device list in the web interface does not list device paths, but instead the filename in /dev/serial/*
  • The list must somehow be filtered to not include the in-use GPS device. Not sure how to do this properly.. probably need to follow symlink of the currently in-use GPS device, and also follow the /dev/serial/* symlink, and if they are the same - skip it (realpath() syscall?).

Alternative solution:
Screw all this /dev/* path trickery to guess stuff, and use udev instead.. I had started to implement this in the "devicemanager" branch a while back, but it's nowhere near finished.. seems like a lot of work.

If you have a better suggestion, please let me know. I'm not that happy with the above either..

// Serial Management with Capabilities and Baud support
case "SerialOutput":
modelItem := val.(map[string]interface{})
if(modelItem["DeviceString"]!=nil && len(modelItem["DeviceString"].(string))>0 &&
Copy link
Collaborator

@b3nn0 b3nn0 May 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please try to follow the coding style here? No () around if-conditions if it's not needed, spaces around operators, ...

main/network.go Outdated
@@ -139,6 +141,8 @@ func serialOutWatcher() {
for i := 0; i < 10; i++ {
serialDevs = append(serialDevs, fmt.Sprintf("/dev/serialout%d", i))
serialDevs = append(serialDevs, fmt.Sprintf("/dev/serialout_nmea%d", i))
// Improved Serial Output support for different devices
serialDevs = append(serialDevs, fmt.Sprintf("/dev/ttyUSB%d", i))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure about this.. this is kinda a catch-all for a lot of devices, including stuff that is intended to be a GPS and not a serialout chip..
Unfortunately it's kinda impossible to guess the intention that a user has when plugging in a certain device.. can we maybe somehow filter to only display devices that are not detected as GPS? Also see my general remark though..

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.

2 participants