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

UART adaptations for modern Raspbian #56

Merged
merged 2 commits into from
Sep 27, 2017
Merged

Conversation

stephanmantler
Copy link
Contributor

  • Modernized tty naming ("serial0" / "serial1")
  • Added 2400 / 4800 speeds
  • Made open() nonblocking (fixes hang on open() call)

- Added 2400 / 4800 speeds
- Made open() nonblocking (fixes hang on open() call)
@uraimo
Copy link
Owner

uraimo commented Sep 26, 2017

Thanks Stephan for submitting this!
The CHIP's Debian does not have those serialn links (yet?), could you revert it to "ttyS0"?

Regarding the links, on my Pi3 with Stretch they point to:

  • serial0 -> ttyS0
  • serial1 -> ttyAMA0

Where AMA0 was the serial accessible via P14-15 that was normally returned by UARTs(for:).
Since you return serial0(S0) for all the Pis before the 3, did something change lately and S0 is now associated with Pin 14-15?
If not, can you return serial1 instead in that case? And also return serial1 first for the Pi3? The idea in all those factories is to always return the most easily reachable (the one that does not need additional config) interface first even if the natural ordering is not followed.

@hpux735
Copy link
Collaborator

hpux735 commented Sep 26, 2017

The names of these device files can vary wildly. I would suggest searching a list of possible serial device names.

Examples include:
ttyS<x>
ttyAMA<x>
ttymxc<x>

@stephanmantler
Copy link
Contributor Author

AFAIK /dev/serial0 etc. are automatically symlinked to the ‘logical’ choice on Raspberry Pi’s (ttyAMA0 on Pi/Pi2; ttyS0 on Pi3) so that should work as intended (I hope).

One nice consequence is that the constructor can be used to instantiate any references to /dev/* directly (and not just /dev/tty*) in case the predefined lists are inaccurate or insufficient (eg. with USB ports).

I’ll revert the change for the CHIP.

@uraimo
Copy link
Owner

uraimo commented Sep 26, 2017

(ttyAMA0 on Pi/Pi2; ttyS0 on Pi3) so that should work as intended (I hope).

Yeah, I could verify it only on the Pi1 but I'm pretty confident that's correct, after reading this (tl;dr: the fast ttyAMA0 is ootb used for the bluetooth chip on Pi3).

I would suggest searching a list of possible serial device names.

Yep, this would definitely be an improvement, making the whole thing less static. I'm opening a separate issue for this (#57) since it requires additional considerations.

- refactored SysFSUART init() to take a list of devices to try in order of prefrerence (first successful wins)
@uraimo uraimo merged commit ae99789 into uraimo:master Sep 27, 2017
@stephanmantler
Copy link
Contributor Author

Turns out the non blocking flag requires some additional changes. I’ll submit another pull request soon that reverts non blocking opening (which should really have been a separate patch) and implements the prioritized list approach more or less as discussed.

@uraimo
Copy link
Owner

uraimo commented Sep 28, 2017

Perfect, thanks!

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.

None yet

3 participants