rtems-net: network sema obtain: network not initialised error
chrisj at rtems.org
Sun Mar 24 03:31:29 UTC 2019
On 22/3/19 9:44 pm, 787562067 wrote:
> I called select function , why report this error?
You see this error because the network stack that provides the select call is
not initialised. The select call in the legacy stack (in the RTEMS source tree)
is only for network sockets file descriptors.
Select is specialised for network sockets to make it easy to port standard
> Hello, I'm waiting for input..
> \0wait 5s
> select begin
> rtems-net: network sema obtain: network not initialised
> int uart_recv(int fd, char *rcv_buf,int data_len)
Initialising the network stack will not work with a UART file descriptor, the
select call in the legacy stack is specialised to work only with network sockets.
RTEMS is real-time and threading is used rather than a select type design.
Because threads or tasks are available users tend to create a thread for each
resource you would block on in select and you just call read and block there.
This approach gives you a better design because the overhead to multiplex and
demultiplex descriptors in a select call is avoided and the slowest path latency
for a single select loop for multiple descriptors is avoided.
> int len,fs_sel;
> fd_set fs_read;
> struct timeval time;
> time.tv_sec = 4;
> time.tv_usec = 0;
> printf("select begin\n");
> fs_sel = select(fd+1,&fs_read,NULL,NULL,&time);
Why no just call read and block? You use termios to control timeouts when waiting?
> printf("fs_sel = %d\n",fs_sel);
> len = read(fd,rcv_buf,data_len);
> printf("I am right!(version1.2) len = %d fs_sel = %d\n",len,fs_sel);
> return len;
> printf("Sorry,I am wrong!");
> return FALSE;
> users mailing list
> users at rtems.org
More information about the users