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

Data, parity, stop bit settings and config parsing and formatting #38

Closed
wants to merge 4 commits into from

Conversation

tajtiattila
Copy link
Contributor

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.

@tarm
Copy link
Owner

tarm commented Dec 16, 2015

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?

@tajtiattila
Copy link
Contributor Author

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 tajtiattila@48c5ab6 instead of the whole PR if you think it suits the project better.

@evantill
Copy link

Hi, any update on this PR ?

@tajtiattila
Copy link
Contributor Author

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)

tarm pushed a commit that referenced this pull request Jan 31, 2016
This is discussed in these PRs:
#34
#38
@tarm
Copy link
Owner

tarm commented Jan 31, 2016

I merged the first 3 commits. Thanks Attila!

@evantill
Copy link

thank you @tarm and @tajtiattila 👍

TopOneExpert added a commit to TopOneExpert/go_serial-port that referenced this pull request Oct 19, 2020
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.

3 participants