try setting
tio.c_cc[VMIN] = 1;
-----Original Message-----
From: Maymi, F. MAJ EECS [mailto:Fernando.Maymi@usma.edu]
Sent: Wednesday, November 24, 2004 2:24 PM
To: gumstix-users@lists.sourceforge.net
Subject: [Gumstix-users] Serial port programming problem (someone please help)

I have a piece of code that configures a radio transceiver connected to a serial port (see below). I can run this on my Fedora Core 2 box with no problems. When I cross-compile it and run it on the Gumstix (/dev/ttyS3 HWUART), the read() operations always fail. I put a serial sniffer online and can see that the gumstix is transmitting the right data and that the radio module is replying correctly. These replies, however, never make it into my serial port's input buffer. Can anyone offer any help at all? I've spent several days trying to solve this one and could really use a bit more sleep! Thanks.
 
 
int configureRadioPort()
{
    char c, str[80], cmd[80];
    FILE *fp;
    int return_value = 1, result;
    struct termios tio;
 
    if((tty = open( dev_com, O_RDWR | O_NOCTTY )) < 0)
    {
      return_value = 0;
      logEvent( log_file,
           "Error attempting to configure the radio port.\n" );
      }
    else
    {
      //get the current port settings
      fcntl( tty, F_SETFL, 0 );
      tcgetattr( tty, &tio ); 
 
      //enable raw (non-canonical) input
      tio.c_cflag |= ( CLOCAL | CREAD );
      tio.c_cflag &= ~CRTSCTS;   //disable HW flow control
      tio.c_cflag &= ~PARENB;    //no parity
      tio.c_cflag &= ~CSTOPB;    //no stop bit
      tio.c_cflag &= ~CSIZE;     //clear the size bits
      tio.c_cflag |= CS8;     //8 data bits
      tio.c_iflag &= ~( IXON | IXOFF | IXANY ); //disable SW flow control
      tio.c_iflag |= IGNPAR;     //ignore parity errors
      tio.c_lflag &= ~( ICANON | ECHO | ECHOE | ISIG ); //non-canonical
      tio.c_lflag |= ( PENDIN | NOFLSH ); //
      tio.c_oflag &= ~OPOST;    //
      tio.c_oflag &= ~(NLDLY|CRDLY|TABDLY|BSDLY|VTDLY|FFDLY); //no delays
 
      //we don't want to block indefinitely on reads
      tio.c_cc[VMIN] = 0;
      tio.c_cc[VTIME] = 15; //tenths of a second
 
      // now, set the speed 
      cfsetispeed( &tio, B9600 );
      cfsetospeed( &tio, B9600 );
      tcsetattr( tty, TCSANOW, &tio );
 
      // enter command mode
      tcflush( tty, TCIOFLUSH );
      result = write( tty, "+++", 3 );
 
     // read the response and ensure it was OK
      str[0] = '\0';
      result = read( tty, str, 80 );
      if ( strncmp( str, "OK", 2 ) != 0 )
      {
           return_value = 0;
           logEvent( log_file, "Error entering command mode.\n" );
      }
 
      // set the power level to 500 mW
      result = write( tty, "ATPL3\r", 6 );
 
     // read the response and ensure it was OK
      str[0] = '\0';
      result = read( tty, str, 80 );
      if ( strncmp( str, "OK", 2 ) != 0 )
      {
           return_value = 0;
           logEvent( log_file, "Error setting the radio power level.\n" );
      }
 
      // exit command mode
      result = write( tty, "ATCN\r", 5 );
 
     // read the response and ensure it was OK
      str[0] = '\0';
      result = read( tty, str, 80 );
      if ( strncmp( str, "OK", 2 ) != 0 )
      {
           printf( "Error finishing radio configuration.\n" );
      }
 }
 
 return return_value;
}