Closed tajtiattila closed 8 years ago
Commits 1-3 look good to me.
Can you explain the use case for commit 4 a little bit? Is that string format standard in any way? Why would someone want to input or output that?
I just wanted a way to specify data, parity and stop bits setting, so a GUI or command line app can easily parse them without knowing much about serial ports. That's the purpose of ParseSettings/FormatSettings. After that I added ParseConfig/Config.String() to the mix because it looked like the next logical thing to do.
I saw this format for the (data, parity, stop) settings on wikipedia but must admit I haven't checked any references on the topic. The format for ParseConfig() and Config.String() is my own invention, I'm afraid.
Feel free to merge the commit https://github.com/tajtiattila/serial/commit/48c5ab6fe68fbf7570f41c3dc053c06dfcc18750 instead of the whole PR if you think it suits the project better.
Hi, any update on this PR ?
I believe the problem is that we couldn't came to a conclusion about the best representation for stop bits. I think using a float for stop bits would be a bad idea. @tarm did you look at my reply where I looked at serial libraries in other languages?
How about this: remove the StopBits
type and use just byte
. Have only a constant StopBits1Point5 = 3
and state in the documentation that the only values accepted would be 0, 1, 2 or StopBits1Point5, otherwise Open would panic. (0 is there to have a valid zero value, and would map to 1 for backwards compatibility)
I merged the first 3 commits. Thanks Attila!
thank you @tarm and @tajtiattila :+1:
The first commit is the PR #34 from @paocalvi squashed and cleaned up to use the go naming convention. It return errors for unsupported configuration instead of using defaults.
The second commit replaces naked returns to use arguments in some function(s). Naked returns should be used only in short functions.
The third commit just adds a build tag so that I could test format.go on windows.
The fourth commit adds code to format and parse serial configurations, useful for command line argument handling.