Open cormacc opened 8 years ago
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.
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 https://github.com/EmergingTechnologyAdvisors/node-serialport/blob/master/src/serialport_win.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.