On Sun, Nov 24, 2019 at 7:53 PM Jeffrey Walton <noloa...@gmail.com> wrote:

> On Sun, Nov 24, 2019 at 10:10 PM Philip Guenther <guent...@gmail.com>
> wrote:
> >
> > On Sun, Nov 24, 2019 at 3:11 AM Jeffrey Walton <noloa...@gmail.com>
> wrote:
> >>
> >> I am struggling to get a USB modem and terminal configured properly
> >> under OpenBSD. The same code on Linux is fine. The symptom I am seeing
> >> is a hung read() after issuing ATZ\r to the modem.
> >>
> >> I'm guessing there's an uninitialized field in my struct termios tty.
> >
> > I'm not sure what you mean by that.  Do you mean you're concerned that
> you're you making a tcsetattr(3) call on an incompletely initialized
> structure?  Or do you mean you're concerned that the initial configuration
> of the tty provided by the kernel is in a "not good" state?
>
> I think cfmakeraw is not initializing the structure properly. It is an
> intermittent failure.
>

This code is misusing cfmakeraw(3): it needs to call tcgetattr(3) on the
tty fd and only call cfmakeraw() on the termios structure that tcgetattr()
has filled in.

(There may be other problems; I only reviewed enough to see that it was
violating the rule I mentioned in my previous post.  The _only_ portable
way to initialize a struct termios is to use tcgetattr()!)


Philip Guenther

Reply via email to