[Toybox] Android microcom questions.
enh at google.com
Fri Aug 17 11:17:11 PDT 2018
On Fri, Aug 17, 2018 at 10:08 AM Rob Landley <rob at landley.net> wrote:
> Microcom says it's from "the android open source project", so presumably I
> should send questions that way: Why do you open the tty in nonblocking
> mode and
> then immediately switch to blocking mode for the reads (guarded by poll so
> shouldn't block anyway)? Are there ttys that hang on open?
iirc i took this behavior from the little tool that Android folks were
using before. i suspect this snippet has been copied since the dawn of
time, with no-one brave enough to remove it to see if it's still useful in
2018 (where all my serial ports at least are actually USB).
> I remember testing whether a CDROM drive had a CD in it without waiting to
> it up involves trying to open the block device in nonblock mode and seeing
> error message you get. Presumably you can pull a similar trick on external
> drives that spin down if you don't want to wait for them. But I dunno how
> applies to char devices?
> I'm combining xraw() with set_terminal(), and moving the speed setting
> into set_terminal. And while we're at it:
> $ echo hello | toybox microcom -s 115200 /dev/ttyS0
> microcom: tcgetattr fd: I/O error
> (I think about these things because "toybox expect" is on my post-1.0 todo
> list.) And if xraw() fails on stdin we haven't set up the signal handler
> yet and
> don't restore the tty state? Dunno if it matters...
> Heh. If you run "toybox top | cat" and then ctrl-c to kill it, the cursor
> display isn't reenabled and the _reason_ is it was disabled by an ANSI
> sequence and the signal handler that re-enables it outputs the
> ANSI escape sequence... which can't make it out through cat if the ctrl-c
> the whole pipeline.
> I'm calling that one pilot error, largely because I dunno how to fix it.
> tcsetattr call takes it back out of raw mode, but the tcsetattr man page
> contain the word "cursor"...)
> Toybox mailing list
> Toybox at lists.landley.net
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Toybox