A piece of sample code that does not work... the code hangs when going into the loop as best as I can tell. If I take the delay wether it be sleep, usleep, or select via timeout it hangs.
Why is this happening? I have no clue. It hangs the same way on regular linux systems.... never had this problem before. Maybe I am just passing over something simple.
Code as follows:
// ********************************************************************************
// **
// ** select timeout timing test
// **
// ********************************************************************************
// OS Provided Includes# include <sys/stat.h># include <sys/signal.h># include <sys/select.h># include <sys/types.h># include <time.h># include <fcntl.h># include <stdio.h># include <string.h># include <math.h>
int main(void)
{
int counter = 0;
struct timeval timeout;
printf("..................\n");
printf("serial receive test\n");
// The main loop
// ... essentially just sleep and print every 1 second
for (counter = 0; counter < 100; counter++)
{
// Print out a .
printf(".");
/*
// Sleep for 1 second
timeout.tv_sec = 0;
timeout.tv_usec = 1000000;
select(0, NULL, NULL, NULL, &timeout);
*/
usleep(1000000);
//sleep(1);
//printf(".");
}
printf("\n");
return TRUE;
}