Communication to an external modem with HAYES commands CODE problems...

Communication to an external modem with HAYES commands CODE problems...

Post by Julius Caesa » Thu, 28 Dec 2000 22:22:58



Hi!

Ok, I'm new on linux C system programmation. I'd like to communicate
with my external modem (with AT's commands) with a simple software I
would have written.

I tried to write one, but it doesn't operate... I don't know what's the
problem, that's why I ask your help. Here is the code i've written. My
modem doesn't compose the AT command (in 'buff')

Thank you for your help!!

JC

CODE:
*****

#include <stdio.h>
#include <termios.h>
#include <sys/types.h>
#include <fcntl.h>

#define BAUDRATE B57600
#define MODEMDEVICE "/dev/ttyS0"        /* COM1 */

int main ()
{
        int fd;
        struct termios oldtio,newtio;
        char buff[255]="ATDT0497063344\n";      /* Commande AT */

        fd=open (MODEMDEVICE, O_RDWR);  /* Ouverture du file descr. */
        if(fd < 0)
        {
                perror(MODEMDEVICE);
                exit(-1);
        }

        tcgetattr(fd,&oldtio);          /* sauv. du termios prec. */    

        newtio.c_cflag= BAUDRATE | CS8 | CLOCAL;
        newtio.c_iflag= IGNBRK | IGNPAR;
        newtio.c_oflag= 0;
        newtio.c_lflag= ICANON;
        newtio.c_cc[VMIN]=1;
        newtio.c_cc[VTIME]=0;

        tcflush(fd, TCIFLUSH);
        tcsetattr(fd, TCSANOW, &newtio);        /* nouv. termios */

        if (write(fd,buff,255)== -1)            /* Envoi au modem */
                fprintf(stdout,"Erreur du WRITE\n",255);

        tcsetattr(fd,TCSANOW,&oldtio);          /* Rcup. vieux termios
*/

        close(fd);
        fprintf(stdout,"END\n");
        exit(0);

Quote:}

 
 
 

1. Newbie with a Hayes Optima 336 external modem

I recently "inherited" an external  Hayes Optima 336
V.34/V.FC modem with voice and fax capabilities (model 5345
US version 6.20). Unfortunately, I did not also "inherit"
any manuals or documentation or software to go with it. I've
been to the website and that and downloaded the User's
Guide. I'm gonna try to get it going on the weekend. In the
interim, I was wondering if anyone out there had any
experiences / tips / tricks I should be apprised of before
attempting this.

Thanks,
Dave

2. System Restore

3. Hayes Accura 56K external modem recently became poor in downloading data

4. Roadmap for XVR graphics cards for workstations (aka XVR-1000 vs XVR-1200).

5. Hayes Accura External Modem Configuration

6. Displaying a Message before login??

7. Hayes 56k External modem compatability with Linux

8. Webserver status app

9. how2 use Hayes Accura 33.6 external modem under FreeBSD ?

10. Hayes 336 fax/modem PCMCIA problem w/RH 6.1 -- can't activate modem

11. Sending commands to a Hayes Modem through UNIX?

12. Where to get sources code of Linux external commands

13. HDLC source code using external modem for Solaris