So I have been trying to write code to read data asynchronously from a
serial port. I have tried it with /dev/ttyO1 (using UART1), and also with
/dev/ttyUSB0 (using an FTDI USB cable in the USB port).
Here is a snippet of code. This fails on both serial ports, but in
different manners:
void readSerial( int fd )
{
fd_set readfs;
FD_ZERO( &readfs );
FD_SET( fd, &readfs );
while( 1 )
{
select( fd+1, &readfs, 0, 0, 0 );
if (FD_ISSET( fd, &readfs ))
{
char buffer[32];
int n = read( fd, buffer, 32 );
printf( buffer ); fflush( stdout );
}
}
}
On /dev/ttyO1, the select() call blocks permanently, with no input being
acknowledged. On /dev/ttyUSB0, the function prints EVERY OTHER character,
so if I type "connect" into my PC terminal program, I will get either
"cnet" or "onc" depending on what came before. Either way, it appears
select() is broken because if I replace this with
while((n= read(fd,buffer,32)) > 0)
{
printf(buffer); fflush(stdout);
}
Then I get "connect" as expected on /dev/ttyUSB0 (untried as yet on
/dev/ttyO1). This seems like a fundamental problem with the Angstrom kernel?
--
For more options, visit http://beagleboard.org/discuss
---
You received this message because you are subscribed to the Google Groups
"BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.