Hi everyone
I am trying to read input from my modem, a winmodem under linux 2.4.22 (slackware)
From my C program, I send ATS0=1 command, it answers OK, but after a while, it keeps telling me "NO CARRIER".

The modem is a FB Pctel AMR 6wICHN 357-14M5E. I couldn't find a better driver than slmdm-2.7.10 (it is the only driver that seems to work) I used minicom, and kppp and they seem to be glad with the driver installed.

I wonder why ioctl-TIOCMSET calls don't change status in the modem, what am I missing to make the modem answer data instead of NO CARRIER?
Here's my C program...

#include <termios.h>
#include <stdio.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <sys/signal.h>

#define DEVICE "/dev/ttySL0"
#define PARAMS O_RDWR | O_NOCTTY | O_NONBLOCK | O_NDELAY
#define _POSIX_SOURCE 1 // POSIX compliant source
#define FALSE 0
#define TRUE 1

volatile int STOP=FALSE;
int wait_flag = TRUE;

//Para la Conexion
int devFd; //File Descriptor for modem
struct termios oldtio,newtio;

void quitOK();
void signal_handler_IO(int);

main(int argc, char *argv[])
{
char buf[255];
int r;
struct sigaction saio;
unsigned int mstat = 0;

devFd = open(DEVICE, PARAMS);
if (devFd <0) {perror(DEVICE); exit(-1); }

saio.sa_handler = signal_handler_IO;
//saio.sa_mask = 0;
saio.sa_flags = 0;
saio.sa_restorer = NULL;
sigaction(SIGIO,&saio,NULL);

//Allow the process to receive SIGIO
fcntl(devFd, F_SETOWN, getpid());
// Make file descriptor asynchronous
if (fcntl(devFd, F_SETFL,FASYNC)==-1) perror("fcntl"); //Probar con FNDELAY

//Save current port settings
bzero(&oldtio, sizeof(oldtio));
bzero(&newtio, sizeof(newtio));

if (tcgetattr(devFd,&oldtio)==-1) {perror("tcgetattr old");exit(0);}

newtio.c_cc[VMIN]=5;
newtio.c_cc[VTIME]=0;
newtio.c_cflag &= ~(CSIZE|CSTOPB|PARENB|CRTSCTS|HUPCL);
newtio.c_cflag |= (CREAD|CS8|CLOCAL);
newtio.c_iflag &= ~(PARMRK|INPCK|INLCR);
newtio.c_iflag &= ~(IGNBRK|IGNCR|IGNPAR|BRKINT|ISTRIP|IUCLC|ICRNL|IX ANY);
newtio.c_iflag |= (IXOFF|IXON);
newtio.c_oflag = 0;
newtio.c_lflag = 0;


if (cfsetispeed(&newtio,B9600) == -1) perror("ispeed");
if (cfsetospeed(&newtio,B9600) == -1) perror("ospeed");

if (tcflush(devFd,TCIOFLUSH) == -1) perror("tcflush");
if (tcsetattr(devFd,TCSANOW,&newtio) == -1) perror("tcsetattr");

//ATS0=1 Autoanswer
if (write(devFd,"ATS0=1\r",7) == -1) perror("write ATS0");

//Waiting for input from MODEM

while (STOP == FALSE) {
if (wait_flag == FALSE) {
mstat = TIOCM_RTS; // | TIOCM_DSR;
if (ioctl(devFd,TIOCMSET,&mstat) == -1) perror("ioctl TIOCMSET");
printf("TIOCMSET %d\n", mstat);

if (ioctl(devFd,TIOCMGET,&mstat) == -1) perror("ioctl TIOCMGET");
printf("TIOCMGET %d\n", mstat);

bzero(&buf, sizeof(buf));
r = read(devFd,buf,255);
if (r == -1) perror("read");
if (r > 0 ) printf("buf=%s",buf);
wait_flag = TRUE;
}
}

}

void signal_handler_IO(int status)
{
printf("Signal %d \n",status);
wait_flag = FALSE;
}


//Cierra el disp. al presionar Ctrl-C
void quitOK()
{
cfsetispeed(&oldtio,B0);
cfsetospeed(&oldtio,B0);
if (tcsetattr(devFd,TCSANOW,&oldtio)==-1) perror("last tcsetattr");
close(devFd);
exit(0);
}


That gives me this

Signal 29
TIOCMSET 4
TIOCMGET 292
buf=ATS0=1
OK
Signal 29
TIOCMSET 4
TIOCMGET 292
buf=
RING
Signal 29
TIOCMSET 4
TIOCMGET 292
buf=
NO CARRIER

Thanks in advance