Looking into this at the moment, it would be super helpful if some of this functionality could be extended for use by plugins.
For my use case, I'd like to:
- Let the user see all available COM ports in my plugin settings, with extra info to identify what's plugged in, so that they can select one or more for the plugin to connect to
- Store the selected device/port, and use it for collecting sensor data
- Check that the device is still present after restart, and safely handle when it isn't
- Prevent the user from accidentally selecting the Printer COM port
- I'm sure I'll think of more edge cases that should be handled...
Looking at get_connection_options(), it looks like the fundamentals I'd need for this are already in place, and I could override them if needed (for example, if I'm dealing with a sensor that only handles a particular baudrate subset, I could just override that) and leave the rest). I won't touch any of this for now, as you said it's going to burn, but for future consideration this would sure be helpful.
For now, I'm just going to use PySerial list_ports to spit out a list, let the user pick one, and hope it's still there later. It feels like building proper handling of serial devices for one plugin is a bit overkill, there must be other plugins that could make good use of this as common functionality.
What do you think? Could be an official "SensorManager" plugin installed as a dependency by other plugins that use sensors?