Usenet comp.sys.dec (1990-2013)
 help / color / mirror / Atom feed
From: A.Raman@massey.ac.nz (Anand V Raman)
Subject: Talking to a modem on a lat port
Date: Wed, 26 May 93 02:16:32 GMT	[thread overview]
Message-ID: <1993May26.021632.9389@massey.ac.nz> (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


                 reply	other threads:[~1993-05-26  2:16 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox