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

support for non standard baud rates if tcsetattr fails #49

Closed
wants to merge 3 commits into from

Conversation

azplanlos
Copy link
Contributor

update for pull request #46 as discussed there.

Support for non standard baud rates if setting port attributes fail as fallback including error handling and notifying delegate.

Successfully tested with Junsi iCharger (CP210x chipset) at 128000 baud.

@armadsen
Copy link
Owner

I'm struggling a bit with this because non-standard baud rates are not universally supported. For example, after this change, setting the baud rate to 128000 on my Keyspan adapters seems to work. tcsetattr() fails, but the subsequent call to ioctl() doesn't return an error, so the ORSSerialPort delegate is never notified of an error. However, the baud rate is not in fact set to 128000, and there's no way for the user of ORSSerialPort to detect this programatically.

This could be worked around if it were possible to reliably read the actual baud rate of the port, but as far as I can tell, baud rates set with IOSSIOSPEED are not readable (e.g. using cfgetispeed() on the termios returned by tcgetattr()).

This is essentially the same issue that caused me to hesitate on #45. It seems like the options are:

  • Continue not supporting non-standard baud rates. (Obviously I'd rather support them.)
  • Thoroughly document this behavior with the caveat that it doesn't work with all USB to serial adapters/drivers and should be used with caution.
  • Make support for non-standard baud rates configurable. e.g. an allowsNonStandardBaudRates property.
  • Make setting a nonstandard baud rate require the use of a different property, e.g. -setNonStandardBaudRate:.
  • ???

Any thoughts?

@azplanlos
Copy link
Contributor Author

This is an issue related to OS X and Linux as discussed in various forums around the net. It seems like some 3rd party drivers (like the one I tested) are supporting these bitrates but the OS definately does not and most probably will not. For this I favour your suggestion of introducing a property for this behaviour. Most probably it should be off by default as this is what you would expect from the OS side. I vote for a allowsNonStandardBaudRates property with a default value of NO.

Andreas Zöllner
Sent with Airmail

Absender: Andrew Madsen notifications@github.commailto:notifications@github.com
Antworten: armadsen/ORSSerialPort reply@reply.github.commailto:reply@reply.github.com
Datum: 28. März 2015 at 18:20:07
Empfänger: armadsen/ORSSerialPort orsserialport@noreply.github.commailto:orsserialport@noreply.github.com
CC: Andreas Zöllner andi@go-for-fun.demailto:andi@go-for-fun.de
Betreff: Re: [ORSSerialPort] support for non standard baud rates if tcsetattr fails (#49)

I'm struggling a bit with this because non-standard baud rates are not universally supported. For example, after this change, setting the baud rate to 128000 on my Keyspan adapters seems to work. tcsetattr() fails, but the subsequent call to ioctl() doesn't return an error, so the ORSSerialPort delegate is never notified of an error. However, the baud rate is not in fact set to 128000, and there's no way for the user of ORSSerialPort to detect this programatically.

This could be worked around if it were possible to reliably read the actual baud rate of the port, but as far as I can tell, baud rates set with IOSSIOSPEED are not readable (e.g. using cfgetispeed() on the termios returned by tcgetattr()).

This is essentially the same issue that caused me to hesitate on #45#45. It seems like the options are:

  • Continue not supporting non-standard baud rates. (Obviously I'd rather support them.)
  • Thoroughly document this behavior with the caveat that it doesn't work with all USB to serial adapters/drivers and should be used with caution.
  • Make support for non-standard baud rates configurable. e.g. an allowsNonStandardBaudRates property.
  • Make setting a nonstandard baud rate require the use of a different property, e.g. -setNonStandardBaudRate:.
  • ???

Any thoughts?


Reply to this email directly or view it on GitHubhttps://github.com//pull/49#issuecomment-87256637.

@armadsen
Copy link
Owner

armadsen commented Apr 5, 2015

Redoing this to make sure @azplanlos gets credit.

@armadsen
Copy link
Owner

armadsen commented Apr 5, 2015

OK, manually merged this into 1.8.0 in eae268b . Thanks again!

@armadsen armadsen closed this Apr 5, 2015
armadsen added a commit that referenced this pull request Apr 5, 2015
@azplanlos
Copy link
Contributor Author

Thanks!

@armadsen armadsen mentioned this pull request Apr 14, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants