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

787562067 googcheng at qq.com
Tue Mar 26 07:51:55 UTC 2019


thanks for the reply, i use select because the read function does not work well, so i try it maybe you could see my other topics



------------------ 原始邮件 ------------------
发件人: "Chris Johns"<chrisj at rtems.org>; 
发送时间: 2019年3月24日(星期天) 中午11:31
收件人: "787562067"<googcheng at qq.com>; "users"<users at rtems.org>; 
主题: Re: rtems-net: network sema obtain: network not initialised error



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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/users/attachments/20190326/6d3f196c/attachment-0001.html>


More information about the users mailing list