From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10b612,5fd24da6a0363793,start X-Google-Attributes: gid10b612,public X-Google-Thread: 1164f8,5fd24da6a0363793,start X-Google-Attributes: gid1164f8,public X-Google-ArrivalTime: 1993-05-25 19:26:26 PST Xref: gmd.de comp.unix.ultrix:9352 comp.sys.dec:7909 Path: gmd.de!Germany.EU.net!mcsun!uunet!math.ohio-state.edu!zaphod.mps.ohio-state.edu!usc!elroy.jpl.nasa.gov!decwrl!waikato.ac.nz!comp.vuw.ac.nz!cc-server4.massey.ac.nz!ARaman Newsgroups: comp.unix.ultrix,comp.sys.dec Subject: Talking to a modem on a lat port Message-ID: <1993May26.021632.9389@massey.ac.nz> From: A.Raman@massey.ac.nz (Anand V Raman) Date: Wed, 26 May 93 02:16:32 GMT Sender: ARaman@massey.ac.nz (Anand V Raman) Organization: Massey University Computing Services 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