Thanks Jan.  I should mention I had wanted to use select() with a socket
opened with AF_PACKET.  It looks like this should work fine though -- I see
reference to af_packet.c in the patch you posted.

I'll have time to write a test program this weekend.  So, unless someone
beats me to it, I'll do it then.

Thanks!

-Rob


On Tue, Aug 19, 2008 at 12:36 PM, Jan Kiszka <[EMAIL PROTECTED]> wrote:

> Jan Kiszka wrote:
> > Gilles Chanteperdrix wrote:
> >> Jan Kiszka wrote:
> >>> Rob Gubler wrote:
> >>>>> There is no select support in RTnet yet. Recent Xenomai does support
> it,
> >>>>> but the (tiny) patch to enable RTnet to use it is not yet merged.
> >>>>>
> >>>>>
> >>>> Back in April Jan posted a reply in regards to select() not yet being
> >>>> supported in Xenomai.   Has the patch Jan mentions above been merged
> into
> >>>> the mainstream project yet?
> >>> Not yet. But this is something we should address quickly. It needs some
> >>> update after the select API of RTDM now matured, and some cleaner
> >>> solution for selecting of write operations [1].
> >> In my later versions of the select support for RTnet, I completely
> >> removed support for selecting of write operations: since select always
> >> return 1, it does not bring any information, and you can not use it in
> >> applications (select would return immediately all the time), so, better
> >> return -EBADF in the select_bind callback.
> >
> > Ah, ok, didn't find that version. Makes sense, will clean up my patch in
> > this regard. It'll be even simpler then.
>
> Just committed this variant. Testers welcome!
>
> Jan
>
> ---
> Index: rtnet/configure
> ===================================================================
> --- rtnet/configure     (Revision 1185)
> +++ rtnet/configure     (Arbeitskopie)
> @@ -21980,6 +21980,17 @@ _ACEOF
>
>  fi
>
> +{ echo "$as_me:$LINENO: checking whether to enable select-like support"
> >&5
> +echo $ECHO_N "checking whether to enable select-like support... $ECHO_C"
> >&6; }
> +if test "$CONFIG_XENO_OPT_RTDM_SELECT" = "y"; then
> +
> +cat >>confdefs.h <<\_ACEOF
> +#define CONFIG_RTNET_SELECT_SUPPORT 1
> +_ACEOF
> +
> +fi
> +{ echo "$as_me:$LINENO: result: ${CONFIG_XENO_OPT_RTDM_SELECT:-n}" >&5
> +echo "${ECHO_T}${CONFIG_XENO_OPT_RTDM_SELECT:-n}" >&6; }
>
>
>
> Index: rtnet/configure.ac
> ===================================================================
> --- rtnet/configure.ac  (Revision 1185)
> +++ rtnet/configure.ac  (Arbeitskopie)
> @@ -1263,6 +1263,11 @@ if test "$CONFIG_RTNET_CHECKED" = "y"; t
>     AC_DEFINE(CONFIG_RTNET_CHECKED, 1, [Bug checks])
>  fi
>
> +AC_MSG_CHECKING([whether to enable select-like support])
> +if test "$CONFIG_XENO_OPT_RTDM_SELECT" = "y"; then
> +    AC_DEFINE(CONFIG_RTNET_SELECT_SUPPORT, 1, [Select support])
> +fi
> +AC_MSG_RESULT([${CONFIG_XENO_OPT_RTDM_SELECT:-n}])
>
>  dnl ======================================================================
>  dnl             hac^H^H^Hfix problem with multible defined symbols problem
> Index: rtnet/stack/ipv4/af_inet.c
> ===================================================================
> --- rtnet/stack/ipv4/af_inet.c  (Revision 1183)
> +++ rtnet/stack/ipv4/af_inet.c  (Arbeitskopie)
> @@ -306,6 +306,9 @@ static struct rtdm_device ipv4_device =
>         .ioctl_nrt =    rt_udp_ioctl,
>         .recvmsg_rt =   rt_udp_recvmsg,
>         .sendmsg_rt =   rt_udp_sendmsg,
> +#ifdef CONFIG_RTNET_SELECT_SUPPORT
> +        .select_bind =  rt_socket_select_bind,
> +#endif
>     },
>
>     .device_class =     RTDM_CLASS_NETWORK,
> Index: rtnet/stack/rtnet_module.c
> ===================================================================
> --- rtnet/stack/rtnet_module.c  (Revision 1183)
> +++ rtnet/stack/rtnet_module.c  (Arbeitskopie)
> @@ -30,6 +30,7 @@
>  #include <rtdev_mgr.h>
>  #include <rtnet_chrdev.h>
>  #include <rtnet_internal.h>
> +#include <rtnet_socket.h>
>  #include <rtnet_rtpc.h>
>  #include <stack_mgr.h>
>  #include <rtwlan.h>
> Index: rtnet/stack/include/rtnet_socket.h
> ===================================================================
> --- rtnet/stack/include/rtnet_socket.h  (Revision 1183)
> +++ rtnet/stack/include/rtnet_socket.h  (Arbeitskopie)
> @@ -89,13 +89,17 @@ static inline struct rtdm_dev_context *r
>  #define rt_socket_dereference(sock) \
>     atomic_dec(&(rt_socket_context(sock)->close_lock_count))
>
> -extern int rt_socket_init(struct rtdm_dev_context *context);
> -extern int rt_socket_cleanup(struct rtdm_dev_context *context);
> -extern int rt_socket_common_ioctl(struct rtdm_dev_context *context,
> -                                  rtdm_user_info_t *user_info,
> -                                  int request, void *arg);
> -extern int rt_socket_if_ioctl(struct rtdm_dev_context *context,
> -                              rtdm_user_info_t *user_info,
> -                              int request, void *arg);
> +int rt_socket_init(struct rtdm_dev_context *context);
> +int rt_socket_cleanup(struct rtdm_dev_context *context);
> +int rt_socket_common_ioctl(struct rtdm_dev_context *context,
> +                           rtdm_user_info_t *user_info,
> +                           int request, void *arg);
> +int rt_socket_if_ioctl(struct rtdm_dev_context *context,
> +                       rtdm_user_info_t *user_info,
> +                       int request, void *arg);
> +int rt_socket_select_bind(struct rtdm_dev_context *context,
> +                          rtdm_selector_t *selector,
> +                          enum rtdm_selecttype type,
> +                          unsigned fd_index);
>
>  #endif  /* __RTNET_SOCKET_H_ */
> Index: rtnet/stack/packet/af_packet.c
> ===================================================================
> --- rtnet/stack/packet/af_packet.c      (Revision 1183)
> +++ rtnet/stack/packet/af_packet.c      (Arbeitskopie)
> @@ -466,7 +466,10 @@ static struct rtdm_device   packet_proto
>         .ioctl_rt =     rt_packet_ioctl,
>         .ioctl_nrt =    rt_packet_ioctl,
>         .recvmsg_rt =   rt_packet_recvmsg,
> -        .sendmsg_rt =   rt_packet_sendmsg
> +        .sendmsg_rt =   rt_packet_sendmsg,
> +#ifdef CONFIG_RTNET_SELECT_SUPPORT
> +        .select_bind =  rt_socket_select_bind,
> +#endif
>     },
>
>     .device_class =     RTDM_CLASS_NETWORK,
> @@ -496,7 +499,10 @@ static struct rtdm_device   raw_packet_p
>         .ioctl_rt =     rt_packet_ioctl,
>         .ioctl_nrt =    rt_packet_ioctl,
>         .recvmsg_rt =   rt_packet_recvmsg,
> -        .sendmsg_rt =   rt_packet_sendmsg
> +        .sendmsg_rt =   rt_packet_sendmsg,
> +#ifdef CONFIG_RTNET_SELECT_SUPPORT
> +        .select_bind =  rt_socket_select_bind,
> +#endif
>     },
>
>     .device_class =     RTDM_CLASS_NETWORK,
> Index: rtnet/stack/socket.c
> ===================================================================
> --- rtnet/stack/socket.c        (Revision 1183)
> +++ rtnet/stack/socket.c        (Arbeitskopie)
> @@ -290,6 +290,30 @@ int rt_socket_if_ioctl(struct rtdm_dev_c
>  }
>
>
> +#ifdef CONFIG_RTNET_SELECT_SUPPORT
> +int rt_socket_select_bind(struct rtdm_dev_context *context,
> +                          rtdm_selector_t *selector,
> +                          enum rtdm_selecttype type,
> +                          unsigned fd_index)
> +{
> +    struct rtsocket *sock = (struct rtsocket *)&context->dev_private;
> +
> +    switch (type) {
> +        case XNSELECT_READ:
> +            return rtdm_sem_select_bind(&sock->pending_sem, selector,
> +                                        XNSELECT_READ, fd_index);
> +        default:
> +            return -EBADF;
> +    }
> +
> +    return -EINVAL;
> +}
> +
> +EXPORT_SYMBOL(rt_socket_select_bind);
> +#endif /* CONFIG_RTNET_SELECT_SUPPORT */
> +
> +
> +
>  EXPORT_SYMBOL(rt_socket_init);
>  EXPORT_SYMBOL(rt_socket_cleanup);
>  EXPORT_SYMBOL(rt_socket_common_ioctl);
> Index: rtnet/config/rtnet_config_pre.h.in
> ===================================================================
> --- rtnet/config/rtnet_config_pre.h.in  (Revision 1185)
> +++ rtnet/config/rtnet_config_pre.h.in  (Arbeitskopie)
> @@ -66,6 +66,9 @@
>  /* RX-FIFO size */
>  #undef CONFIG_RTNET_RX_FIFO_SIZE
>
> +/* Select support */
> +#undef CONFIG_RTNET_SELECT_SUPPORT
> +
>  /* TDMA master support */
>  #undef CONFIG_RTNET_TDMA_MASTER
>
>
>
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
RTnet-users mailing list
RTnet-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rtnet-users

Reply via email to