* Talking to a modem on a lat port
@ 1993-05-26 2:16 Anand V Raman
0 siblings, 0 replies; only message in thread
From: Anand V Raman @ 1993-05-26 2:16 UTC (permalink / raw)
Hi,
This is a follow-up article to one I posted in comp.unix.ultrix.
I have actually got the modem going now and I can talk to it, but
for some reason the conversation is not consistent. Here's the
essentials of the test program: I'll bet there are some glaring
mistakes that are obvious to LAT gurus out there.
(the modem is lat mounted on /dev/tty02)
fd = open("/dev/tty02", O_RDWR | O_NDELAY);
sleep(1);
on = 1; off = 0; temp = 0;
ioctl(fd, TIOCHPCL, 0);
ioctl(fd, FIONBIO, &on);
ioctl(fd,TIOCGETP,(char *)&term);
term.sg_flags = RAW;
term.sg_flags &= ~(ECHO);
ioctl(fd,TIOCSETP,(char *)&term);
sleep(1);
write(fd, "at&v\r\n, 6);
sleep(1);
while ((c = read(fd, buf, BUFSIZ)) > 0)
write(1, buf, c);
The code only works with the sleep()s in it. Now when it sends
the at&v across to the modem, it receives the active profile, but
somehow the receive process is aborted halfway through. The read
returns with EWOULDBLOCK. If I don't ioctl(FIONBIO) on fd, then
it blocks forever, so the ioctl was necessary. Also it doesn't
always stop receiving chars from the port at the same point.
Sometimes I get half the profile (typically up to the S registers)
sometimes just a few characters, and many times nothing at all. The
program just starts up, sleeps() those seconds, and exits with a
EWOULDBLOCK on the very first read.
What's going on? What have I missed doing? Or rather, how should I
be doing this? I need to set up a good rapport with the modem so
I can get it to connect me to pacnet where the majority of the work
needs to be done!
Help please!!
--
anand v raman
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~1993-05-26 2:16 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1993-05-26 2:16 Talking to a modem on a lat port Anand V Raman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox