On 1/9/20 6:14 am, Cudmore, Alan P. (GSFC-5820) wrote: > I am having problems using the “select” call with an RTEMS + LibBSD network > socket. > > Here is what I am using: > > RTEMS 5.1 RSB, RTEMS source, and RTEMS LibBSD release files. > > ARM/Beagleboneblack + LibBSD > > I have verified that the network is initialized (ethernet device on the > beaglebone) and I can receive UDP packets from the network. >
Great. I use the shell and the `ifconfig` and `netstat` commands. You also have `tcpdump` which is rather useful. > I’m trying to use “select” to check the socket (using a timeout of zero), but > when I call select I get a -1 return code with EBADF errno. I suspect you have hit the FD set size limit. > The fd in this instance is 77 and I have RTEMS setup for 200 file descriptors. > Are there any other LibBSD configuration parameters I should be aware of? I am sorry but 77 is to high because newlib by default limits the fd set size to 64... # ifndef FD_SETSIZE # define FD_SETSIZE 64 # endif I suggest you define `FD_SETSIZE` on the command line to the compiler to 256 and see what happens. It should be fine to do this. > When I build a SPARC/LEON3 BSP with the RTEMS legacy network stack, the select > call seems to work. Admittedly I am just doing this on the loopback interface > on > QEMU since I do not have a real or simulated ethernet device to use. But the > select call seems to work as I would expect in this instance. What is the fd for that stack? I suspect the fd is less than 64. > Is there any setup I need to do, or perhaps the select call operates > differently > with LibBSD? The only difference I know of is signals are not supported in libbsd so a signal will not wake a select call. For code you write we suggest you look at the kqueue set of calls. These provide a better and more efficient interface for blocking on sockets. > Does it work on a UDP socket? Yes. > If I wanted to continue debugging, is the select call in the libbsd source > tree? Yes select is in libbsd and called kern_select ... https://git.rtems.org/rtems-libbsd/tree/freebsd/sys/kern/sys_generic.c#n983 Notice the calls to check the fds .. select_check_badfd(). The code is a little lower down in the file. Chris _______________________________________________ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel