[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Help serial port communication



Carey Evans wrote:

> "Jens B. Jorgensen" <jjorgens@bdsinc.com> writes:
>
> > Carey Evans wrote:
>
> [...]
>
> > > I think it's generally necessary to do  O_RDWR|O_NONBLOCK  to open a
> > > disconnected serial port, then set CLOCAL with termios, and finally
> > > turn off O_NONBLOCK with fcntl.  Of course, for just setting the speed
> > > it should be enough to change the open().
> >
> > Oh really? You need O_NONBLOCK eh? Why don't you put your compiler where your speculation is and
> > compile/run the attached program.
>
> OK.  I had to make one small change because I don't have a ttyS0, but
> I do have a modem on ttyS1.
>
> % make testsp
> cc     testsp.c   -o testsp
> % strace ./testsp
> execve("./testsp", ["./testsp"], [/* 31 vars */]) = 0
>     ...
> open("/dev/ttyS1", O_RDWR
>
> It stops at this point, with "TR" lit on my modem.  If I happened to
> have my modem set to auto-answer, and something connected, *then* the
> open() would complete.

> If I already had something on there that had set CLOCAL, like mgetty,
> it would have run through.  BTW:
>

Right. This is why it works on my box. Now the room is fully lit. Isn't it better to share all the
facts than to make a statement which is not exactly true and thereby confuse some poor person who
subsequently ends up banging their head against their monitor at 2am because they don't understand why
a program doesn't work the way they think it should? QED

> % strace ./testsp2
>     ...
> open("/dev/ttyS1", O_RDWR|O_NONBLOCK)   = 3
> ioctl(3, TCGETS, {0x1002 /* B??? */ -opost -isig -icanon -echo ...}) = 0
> ioctl(3, SNDCTL_TMR_START, {B9600 -opost -isig -icanon -echo ...}) = 0
> close(3)                                = 0
> _exit(0)                                = ?

--
Jens B. Jorgensen
jjorgens@bdsinc.com



--
TO UNSUBSCRIBE FROM THIS MAILING LIST: e-mail the word "unsubscribe" to
debian-user-request@lists.debian.org . 
Trouble?  e-mail to templin@bucknell.edu .


Reply to: