rtems-net: network sema obtain: network not initialised error

Chris Johns 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
networking code.

> Hello, I'm waiting for input..
> \0wait 5s 
> select begin
> rtems-net: network sema obtain: network not initialised
> 
> 
> 
> code:
> =============================
> 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;  
>      
>     FD_ZERO(&fs_read);  
>     FD_SET(fd,&fs_read);  
>      
>     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?

Chris

>     printf("fs_sel = %d\n",fs_sel);  
>     if(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;  
>     }  
>     else  
>     {  
> printf("Sorry,I am wrong!");  
> return FALSE;  
>     }       
>> 
> 
> 
> 
> _______________________________________________
> users mailing list
> users at rtems.org
> http://lists.rtems.org/mailman/listinfo/users
> 


More information about the users mailing list