Serial communication problem

Serial communication problem

Post by Espen Waa » Sat, 04 Dec 1993 20:16:08



I'm trying for the first time to make a small program to access a modem
on a tty.

I thought the flow control was handled by the tty-driver, but now
I realize that I probably have to do some flowcontrol. But *HOW* do I do that?
This is basically the code in C which I have coded so far:

   if((fd = open(tty,O_EXCL|O_RDWR))>0)
   {
      fcntl(fd,F_GETLK,&lockStruct);

      lockStruct.l_type = F_WRLCK;
      lockStruct.l_whence = SEEK_SET;
      lockStruct.l_start = 0;
      lockStruct.l_len = 0;

      :
      :

      if(fcntl(fd,F_SETLKW,&lockStruct) == -1)
      {
         :
      }
      else
      {
         :
         :

         tcgetattr(fd, &t);
         t.c_iflag = IGNBRK|IGNPAR|IXANY;
         t.c_oflag = 0;
         t.c_cflag = B1200|CS8|CREAD|HUPCL;
         t.c_lflag = 0;
         t.c_cc[VMIN] = 0;
         t.c_cc[VTIME] = TIMEOUTVAL;
         tcsetattr(f,TCSANOW,&t);
         :
         :

         printf("\n>>: AT&F&D0E0B0S0=2X3\r");
         WritePort(fd,"AT&F&D0E0B0S0=2X3\r",slow);  /* Do pauses between characters */
         sleep(2);

         printf("\n>>: ATDT12345678\r");
         WritePort(fd,"ATDT12345678\r",slow);
         sleep(10);

         ReadPort(fd,answer);
         :

This is all i write or read from the port.
When I run this, all I get is \r\nOK\r\n and then \r\nNO CARRIER\r\n from the modem.
When I use Pcomm or ate i get CONNECT 1200.

I've compiled the program with cc under AIX 3.2 on an RS/6000.
The modem is a 2400 Hayes-modem.

I was told that the init. string for the modem was right, but
how about the rest?

What am I doing wrong? What do I have to add?

Thanks in advance!

--
_____________________________________________________________________

                                      |  mail : Birkebeinervg. 6
The Norwegian Institute of Technology |         N-7031 TRONDHEIM
                                      |         NORWAY
                                      |  phone: +47 73 59 29 72 (work)
(Confuser Science)                    |         +47 73 94 18 44 (home)
_____________________________________________________________________
   "I believe OS/2 is destined to be the most important operating
    system, and possible program, of all time." - Bill Gates, 1987
_____________________________________________________________________

 
 
 

1. Serial Communication Problem

hi.. I have the following problem of receiving 7bit character
data through the serial line. However, if I change the setting
to 8 bits, it works perfectly. The flag setting are as follows :

        if (ioctl(fd, TCGETA, &tbuf) == -1) {printf("ioctl\n"); exit(1);}
        tbuf.c_cflag = ~(PARENB|PARODD|CS8|CSTOPB);
        tbuf.c_cflag = B9600 | CS7 | CREAD | CLOCAL;
        tbuf.c_iflag &= ~(INPCK|ISTRIP|IGNCR|INLCR|ICRNL|IUCLC|IXON|BRKINT);
        tbuf.c_iflag |= IGNPAR;
        tbuf.c_oflag &= ~(OPOST|IXON|OLCUC|ONLCR|OCRNL|ONLRET);
        tbuf.c_lflag &= ~(ECHO|ICANON|ISIG);
        tbuf.c_cc[4] = 1;
        tbuf.c_cc[5] = 2;
        if (ioctl(fd, TCSETAF, &tbuf) == -1) {printf("ioctl2\n"); exit(1);}

the receiving side is also the same configuration as the above. I am trying
to receive 7bit char with no parity and one stop bit. The sending side looks
correct as I have a monitor that tap into the serial port.

In addition, what's the difference between 1 or 2 stop bits ?? when I'm
sending 8bit character, the number of stop bits on both sending and
receiving party can be different yet can still send and receive properly.

Thank you..

2. DNS problem and/or question

3. WEEP: non-trivial (!) serial communication problem

4. How to set URL aliases ???

5. Serial Communication Problem

6. Invalid terminfo.src on SCO Openserver 5.0.2

7. How to set up serial port when programming serial communication

8. Javadoc runtime problems

9. Problems on Serial Communication

10. problem with communication over serial cable

11. Problem with program doing serial communication under Cygwin

12. problems in serial communication