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

Custom baud rate in OSX won't work #57

Closed
JoeMerten opened this issue Dec 15, 2016 · 6 comments
Closed

Custom baud rate in OSX won't work #57

JoeMerten opened this issue Dec 15, 2016 · 6 comments
Labels

Comments

@JoeMerten
Copy link

I'd recently added custom baud rate support for OSX, but after some more testing, I found out that it not work as expected. I'd tested with:

  • OSX El Capitan 10.11.6
  • Ftdi and Prolific adapters

In most cases, the desired custom baud rate will just be substituted by on of the standard baud rates.

I'll investigate it deeper now and hopefully provide a fix soon.

@JoeMerten
Copy link
Author

Some deeper analysis:
cfsetospeed() seems to store the desired baud rate (e.g. 12345) correctly into termios struct (checked by calling cfgetospeed() before tcsetattr() called.
But when then calling term_apply(), tcsetattr() fail with: "Invalid argument".
For my opinion, I have to call ioctl(fd, IOSSIOSPEED, &speed) after tcsetattr() called.

@npat-efault
Copy link
Owner

npat-efault commented Dec 15, 2016

Yes, this could be a solution... See also my comments in PR #59. You must also find a solution for getting tcgetattr() to work with custom baud rates (i.e. a way to read-back the custom baud rate set).

@npat-efault
Copy link
Owner

Also if the high-baud constants for OSX, the ones >= 460800 do not work without the custom ioctls, they should be removed...

@JoeMerten
Copy link
Author

Reading back custom baud rate via tcgetattr() already works with PR #59. The logic is:

  • tcsetattr() applies the termios data to the fd (with faked B9600)
  • ioctl(fd, IOSSIOSPEED, &speed) now applies the real desired baud rate (e.g. 12345) to the fd
  • the following tcgetattr() then puts the 12345 into the termios struct
  • and following cfgetospeed() calls are returning the right custom baud rate

I'd tested this using Ctrl+A+V command.

@JoeMerten
Copy link
Author

Constants: 460800 and 921600 are working without special handing in OSX, so those both can resist.
But e.g. 500k, 1M (and all above) do not, so I'll remove them - or put em into custbaud_osx.h to have them available for Ctrl+A+U/D in case of custom baudrate enabled.

@npat-efault
Copy link
Owner

I would suggest removing them all if custom baud is not enabled. That is: Without custom-baud support, stay with the baudrates defined by the OS.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants