Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
09/26/08 10:05
Read: times


 
#158604 - Probem facing with modem
Hi,
I am trying to communicate with an external modem which is connected on the serial port of set top box. I opened the device /dev/ttys0 and wrote the AT command to the descriptor.while trying to read the response from the modem I am not getting anything.The read is waiting for data.
Instead of modem if I am connecting the set top box serial port to a hyper terminal the AT command which I am sending is getting there in the terminal and the characters which i am typing is reaching in the STB and it's reading by my program and printing it.ie, it is working well for hyper terminal and it's not working for the externel modem.
To make it ready for the modem, what are the things I have to configure and how.Please help me.
I am attaching my program with this.

int main (int argc, char* argv[])
{
int fd;

static char buffRx[RX_BUFF_LENGTH];
int retVal,loopCount;

/* Open the device */
fd = open("/dev/ttyS0", O_RDWR | O_NOCTTY | O_NDELAY);
if (-1 == fd)
{
perror("Open failed");
return -1;
}
printf("the descriptor is %d\n",fd);
fcntl(fd, F_SETFL, 0);

retVal = write(fd,(char*)"ATZ\r",strlen("ATZ\r"));
if(-1 == retVal)
{
perror("write failed\n");
close(fd);
return -1;
}
printf("Write ret value -> %d\n",retVal);
memset(buffRx,0,RX_BUFF_LENGTH);

printf("The content of buffer before reading is \n");
for(loopCount = 0;loopCount <RX_BUFF_LENGTH;loopCount++)
{
printf("%02x ",buffRx[loopCount]);
}
printf("\n");

printf("gloing to read the response from modem\n");
retVal = read(fd,(char*)buffRx,RX_BUFF_LENGTH);
if(-1 == retVal)
{
perror("faield to read response\n");
close(fd);
return -1;
}
printf("ret val = %d\n",retVal);
printf("response is %s\n",buffRx);


printf("The content of buffer after reading is is \n");
for(loopCount = 0;loopCount <RX_BUFF_LENGTH;loopCount++)
{
printf("%02x ",buffRx[loopCount]);
}
printf("\n");
return 0;

}





List of 5 messages in thread
TopicAuthorDate
Probem facing with modem            01/01/70 00:00      
   Handshake signals            01/01/70 00:00      
   /dev/ttys0 ?            01/01/70 00:00      
      It is not necessary a serial port is a serial            01/01/70 00:00      
   Where do you set the baud rate etc?            01/01/70 00:00      

Back to Subject List