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

OSX custom baudrates: fixed and refactored #62

Merged
merged 1 commit into from
Dec 12, 2017

Conversation

JoeMerten
Copy link

See also #57 and #59

Copy link
Owner

@npat-efault npat-efault left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a few remarks...

struct termios tio0;
int baudrate0;

if ( fd >= 3 ) { /* don't apply this workaround for stdin/stdout/stderr */
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why special-case these three? I see no reason to.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On startup (e.g. picocom /dev/tty.usbserial -b12345), I'd observed 2 calls to tcsetattr():

  • tcsetattr(3, 2, 12345)
  • tcsetattr(0, 2, 9600)

For the 2nd call (fd=0=stdin), when it runs into my workaround code, the ioctl(IOSSIOSPEED) call fail with "Inappropriate ioctl for device".

Normally, this should not happen, because I also check for term_baud_std() and I see 9600 baud in this case. But I dont want to rely on, that I always see 9600 baud for the stdin call.

So I decide to don't apply the workaround, if I was called with fd=0 (stdin), fd=1 (stdout) or fd=2 (stderr).

/* Need to undef tcsetattr to get access to the original tcsetattr()
* function inside our module.
*/
#undef tcsetattr
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could also avoid including custbaud_osx.h, instead of the undef... Whatever feels better to you.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's ok as it is.

@JoeMerten
Copy link
Author

Now I'd just tried custom baudrates with FreeBsd (native FreeBsd 11 installation).
Regarding cf[sg]et[io]speed() it behaves similar to OSX. Every baudrate can directly passed as its integer value and this works.
In contrast to OSX we don't need to workaround in tcsetattr(); FreeBsd is more clean and straight forward in this point.
So the approach to support custom baudrates for FreeBsd will be:

  • rename custbaud_osx.[hc] to custbaud_bsd.[hc] (this is still correct, as OSX started as a descendant of BSD)
  • adding #ifdef __FreeBSD__; I'll don't add __OpenBSD__ etc now, as I currently don't have test environment for it
  • adding __APPLE__ around the OSX specific tcsetattr() replacement code

I'll perform the work when this OSX PR is merged.

@JoeMerten
Copy link
Author

might consider merge?

@JoeMerten
Copy link
Author

what matter, won't merge?

@JoeMerten
Copy link
Author

Reminder … what about merging this PR or not?

@JoeMerten
Copy link
Author

No response since about 5 month; stopped activity on this project?

@hmueller01
Copy link

Tx for the patch. Works perfect for me. Needed 74880 baud for ESP8266 ...
Too bad that nobody adds this to the master branch.

@JoeMerten
Copy link
Author

There is no activity on this whole github account since 2016-12-16 and I don't know the reason why.
Hoping Nick Patavalis is well. Seems that he is still active on facebook.

@npat-efault npat-efault merged commit 4d507bb into npat-efault:master Dec 12, 2017
@npat-efault
Copy link
Owner

Sorry guys, some personal issues (which I won't get into here) prevented me from dealing with this for way too long. Finaly merged

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