ts-7000
[Top] [All Lists]

[ts-7000] Re: Failure to read serial comm on TS-7300

To:
Subject: [ts-7000] Re: Failure to read serial comm on TS-7300
From: "yetanotherdjmorris" <>
Date: Tue, 12 Oct 2010 20:49:35 -0000
I had a similar problem last week.
For whatever reason, I set c_cc[VMIN] and c_cc[VTIME] both to zero and it 
seemed to be getting responses.

--- In  "shusshinchi" <> wrote:
>
> As mentioned in the subject. I am not doing anything complicated at all.
> I merely connected a peripheral device to com2 (/dev/ttyAM1). My program
> then sends out a series of bytes out on com2 to the peripheral device
> and the device responds. However, my program gets nothing. "cat
> /dev/ttyAM1" shows nothing either. Below is a sample code that I have
> used to produce this problem. Is there anything that I need to set
> anywhere to enable the OS to receive data on the serial comm link?
> 
> int main ( int argc, char** argv )
> {
>      for ( short c = 0 ; c < argc ; ++c )
>          cout << "[" << c << "] " << argv[c] << endl ;
> 
>      int fd = open ( argv[1], O_RDWR | O_NOCTTY | O_NDELAY ) ;
>      termios port_settings ;
> 
>      cout << "fd = " << fd << endl ;
> 
>      memset ( &port_settings, 0, sizeof port_settings ) ;
>      cfsetispeed ( &port_settings, B9600 ) ;
>      cfsetospeed ( &port_settings, B9600 ) ;
> 
>      port_settings.c_cc[VMIN] = 0 ;
>      port_settings.c_cc[VTIME] = 10 ;
> 
>      port_settings.c_iflag &= ~ICRNL ;
> 
>      port_settings.c_lflag &= ~ICANON ;
> 
>      port_settings.c_cflag &= ~PARENB ;
>      port_settings.c_cflag &= ~CSTOPB ;
>      port_settings.c_cflag &= ~CSIZE ;
>      port_settings.c_cflag &= ~CRTSCTS ;
>      port_settings.c_cflag |= CS8 ;
>      port_settings.c_cflag |= CREAD ;
>      port_settings.c_cflag |= CLOCAL ;
> 
>      tcsetattr ( fd, TCSANOW, &port_settings ) ;
>      tcflush( f d, TCIOFLUSH ) ;
> 
>      char output[ ] = { 0x06, 0x01, 0x00, 0x00, 0x00, 0x10, 0x3c, 0x71 }
> ;
>      short charCount = 0 ;
>      char c ;
>      char cA[8] ;
>      int r ;
> 
>      memset ( cA, 0, 8 ) ;
> 
>      cA[7] = '\0' ;
> 
>      tcflush ( fd, TCIOFLUSH ) ;
>      write ( fd, output, 8 ) ;
> 
>      usleep ( 500000 ) ;
> 
>      cout << "Bytes read = " << ( r = read ( fd, cA, 7 ) ) << endl ; //
> this line fails to read anything
> 
>      tcflush ( fd, TCIOFLUSH ) ;
> 
>      if ( r == -1 )
>      {
>              switch ( errno )
>              {
>                  case EAGAIN : cout << "eagain" << endl ; sleep ( 1 ) ;
> break ;
>                  case EBADF : cout << "ebadf" << endl ; break ;
>                  case EFAULT : cout << "efault" << endl ; break ;
>                  case EINTR : cout << "eintr" << endl ; break ;
>                  case EINVAL : cout << "einval" << endl ; break ;
>                  case EIO : cout << "eio" << endl ; break ;
>                  case EISDIR : cout << "eisdir" << endl ; break ;
>                  default : cout << "errno = " << errno ;
>              }
>      }
> }
>




------------------------------------

Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/ts-7000/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/ts-7000/join
    (Yahoo! ID required)

<*> To change settings via email:
     
    

<*> To unsubscribe from this group, send an email to:
    

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/

<Prev in Thread] Current Thread [Next in Thread>
Admin

Disclaimer: Neither Andrew Taylor nor the University of NSW School of Computer and Engineering take any responsibility for the contents of this archive. It is purely a compilation of material sent by many people to the birding-aus mailing list. It has not been checked for accuracy nor its content verified in any way. If you wish to get material removed from the archive or have other queries about the archive e-mail Andrew Taylor at this address: andrewt@cse.unsw.EDU.AU