Hello,
is it possible to use something like this:
int count;
char buffptr[100];
FILE *ser;
ser = fopen("ttye","a+");
while(1)
{
fd_set rfds;
FD_ZERO(&rfds);
FD_SET(ser->_FD, &rfds);
int res = select(ser->_FD+1, &rfds, NULL, NULL, 500);
if (res == -1) { USB_PRINTF("SELECT ERROR\n "); continue; }
if (res == 0) { USB_PRINTF("SELECT TIMEOUT"); continue; }
if (!FD_ISSET(ser->_FD, &rfds)) { USB_PRINTF("no FD_ISSET"); continue; }
count=read(ser->_FD,buffptr,99);
USB_PRINTF("%d bytes\n",count);
//DO_SOMETHING_WITH_DATA
/* Let the other task run */
_time_delay(1);
}
(that I normaly use in linux) also in KSDK MQX , or is select() intended only for RTCS sockets?
select() in this example alway returns -1 to me, I also tried RTCS_ versions and it didn't help.
I know I can use blocking read() with 1 byte that would block me, but this way I could also find out that there nothing coming using select timeout.
For this example I would also need nonblocking read - opening file not using fopen(), but open() with O_NONBLOCK doesn't help here.
If it's too much trouble, I will stay with 1 byte blocking read
Thanks,
Martin
解決済! 解決策の投稿を見る。
select() in Freescale MQX can work only with RTCS sockets.