Added port list functionality and increased range of baud rates available via serial_posix.go#37
Added port list functionality and increased range of baud rates available via serial_posix.go#37cormacc wants to merge 2 commits intotarm:masterfrom
Conversation
from the gobug.st/serial package and subject to the conditions of its license (which has been reproduced in source as per terms of said license) Updated serial_posix to support full list of termios baud rates (as per existing serial_linux implementation). Moved posixTimeoutValues method from top level serial.go to new serial_x.go source file, as only required for linux and posix implementations.
serial_linux.go
Outdated
There was a problem hiding this comment.
Please don't include the extra dependancy.
|
Thanks for the explanation. From your description, I think it could be OK to include that functionality. Just as OpenPort() has single common implementation with a godoc comment with platform specific openPort()'s, I think it makes sense to have that pattern for ListPorts(). The comment for ListPorts should be very explicit about it being precise on windows, but only a heuristic convenience function on unix platforms. Also please split out the baud rate changes into a separate PR. |
Added ListPorts method in serial.go that delegates to platform implementation called listPorts. Associated godoc explicitly states that posix implementation is just a convenient heuristic. Renamed platform-specific implementations in serial_posix.go and serial_windows.go from GetPortsList to listPorts for consistency. Reverted baud-rate additions in serial_posix.go. May be included a future PR. Corrected erroneous exporting of function in serial_windows.go Tidied up posix implementation of listPorts. Externalised portname filter definition to posix_<platform>.go
|
Think that last commit addresses most of the concerns to date? Specialised the port name regex in posix_darwin, posix_linux, posix_other:
Multiple files for a single regex filter seems a bit excessive, but would lend itself to the per-platform definition of a baud-rate map discussed. |
|
Maybe this could be improved a bit - to include VID, PID and PnP description string. Also, covering darwin, linux and windows. I know, node-serialport does it quite well.. maybe some inspiration could be found there: https://github.com/EmergingTechnologyAdvisors/node-serialport/blob/master/src/serialport_unix.cpp |
Added GetPortsList method to all implementations, shamelessly lifted
from the gobug.st/serial package and subject to the conditions of its
BSD-like license (which has been reproduced in source as per terms of said
license). Experienced stability issues with gobug.st ages back, which is
why I switched and stole.
Updated serial_posix to support full list of termios baud rates (as per
existing serial_linux implementation).
Moved posixTimeoutValues method from top level serial.go to new
serial_x.go source file, as only required for linux and posix
implementations.
A major disclaimer -- not retested on windows and OSX since some refactoring and merging upstream changes over the last day or two, as moved office and only have Linux machines to hand.