* [Xenomai] How setup receive-timeout for rt_dev_recvfrom?
@ 2012-06-28 8:05 Henri Roosen
2012-06-28 8:20 ` Gilles Chanteperdrix
0 siblings, 1 reply; 4+ messages in thread
From: Henri Roosen @ 2012-06-28 8:05 UTC (permalink / raw)
To: xenomai
Hi Xenomai-list,
I am using the native API and RTDM to read from a RTNet realtime interface.
This all works, however, I need a timeout on the rt_dev_recvfrom.
As there is no rt_dev_select function, I tried to setup a receive
timeout, similar to how the XDDP examples do:
{
struct timeval tv;
tv.tv_sec = 1;
tv.tv_usec = 0;
ret = rt_dev_setsockopt(s, SOL_SOCKET, SO_RCVTIMEO,
&tv, sizeof(tv));
if (ret)
fprintf(stderr, "rt_dev_setsockopt: %s\n",
strerror(-ret));
}
Unfortunately this results in "No such device".
Does anyone know how to properly setup a receive timeout?
Thanks,
Henri
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [Xenomai] How setup receive-timeout for rt_dev_recvfrom?
2012-06-28 8:05 [Xenomai] How setup receive-timeout for rt_dev_recvfrom? Henri Roosen
@ 2012-06-28 8:20 ` Gilles Chanteperdrix
2012-07-03 18:08 ` Henri Roosen
0 siblings, 1 reply; 4+ messages in thread
From: Gilles Chanteperdrix @ 2012-06-28 8:20 UTC (permalink / raw)
To: Henri Roosen; +Cc: xenomai
On 06/28/2012 10:05 AM, Henri Roosen wrote:
> Hi Xenomai-list,
>
> I am using the native API and RTDM to read from a RTNet realtime interface.
> This all works, however, I need a timeout on the rt_dev_recvfrom.
>
> As there is no rt_dev_select function, I tried to setup a receive
> timeout, similar to how the XDDP examples do:
The posix skin has select, which can be used by native skin threads. You
have to use the result of socket, and not rt_dev_socket as the fd to put
in the fd_set, but apart from that, it should work.
--
Gilles.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Xenomai] How setup receive-timeout for rt_dev_recvfrom?
2012-06-28 8:20 ` Gilles Chanteperdrix
@ 2012-07-03 18:08 ` Henri Roosen
2012-07-03 21:44 ` Gilles Chanteperdrix
0 siblings, 1 reply; 4+ messages in thread
From: Henri Roosen @ 2012-07-03 18:08 UTC (permalink / raw)
To: Gilles Chanteperdrix; +Cc: xenomai
On Thu, Jun 28, 2012 at 10:20 AM, Gilles Chanteperdrix
<gilles.chanteperdrix@xenomai.org> wrote:
> On 06/28/2012 10:05 AM, Henri Roosen wrote:
>> Hi Xenomai-list,
>>
>> I am using the native API and RTDM to read from a RTNet realtime interface.
>> This all works, however, I need a timeout on the rt_dev_recvfrom.
>>
>> As there is no rt_dev_select function, I tried to setup a receive
>> timeout, similar to how the XDDP examples do:
>
> The posix skin has select, which can be used by native skin threads. You
> have to use the result of socket, and not rt_dev_socket as the fd to put
> in the fd_set, but apart from that, it should work.
Thanks Gilles for your reply! However, I didn't try your suggestion,
because we cannot easily bind the posix skin to our application.
But I found out that RTNet supports setting a timeout on a socket that
is used by rt_dev_recvfrom(). So for the case that anyone is looking
for how to setup a receive timeout, here is what worked for me:
#include <rtnet.h>
nanosecs_rel_t timeout = 1000000000LL;
...
ret = rt_dev_ioctl(s, RTNET_RTIOC_TIMEOUT, &timeout);
Thanks,
Henri.
>
> --
> Gilles.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Xenomai] How setup receive-timeout for rt_dev_recvfrom?
2012-07-03 18:08 ` Henri Roosen
@ 2012-07-03 21:44 ` Gilles Chanteperdrix
0 siblings, 0 replies; 4+ messages in thread
From: Gilles Chanteperdrix @ 2012-07-03 21:44 UTC (permalink / raw)
To: Henri Roosen; +Cc: xenomai
On 07/03/2012 08:08 PM, Henri Roosen wrote:
> On Thu, Jun 28, 2012 at 10:20 AM, Gilles Chanteperdrix
> <gilles.chanteperdrix@xenomai.org> wrote:
>> On 06/28/2012 10:05 AM, Henri Roosen wrote:
>>> Hi Xenomai-list,
>>>
>>> I am using the native API and RTDM to read from a RTNet realtime interface.
>>> This all works, however, I need a timeout on the rt_dev_recvfrom.
>>>
>>> As there is no rt_dev_select function, I tried to setup a receive
>>> timeout, similar to how the XDDP examples do:
>>
>> The posix skin has select, which can be used by native skin threads. You
>> have to use the result of socket, and not rt_dev_socket as the fd to put
>> in the fd_set, but apart from that, it should work.
>
> Thanks Gilles for your reply! However, I didn't try your suggestion,
> because we cannot easily bind the posix skin to our application.
>
> But I found out that RTNet supports setting a timeout on a socket that
> is used by rt_dev_recvfrom(). So for the case that anyone is looking
> for how to setup a receive timeout, here is what worked for me:
>
> #include <rtnet.h>
> nanosecs_rel_t timeout = 1000000000LL;
> ...
> ret = rt_dev_ioctl(s, RTNET_RTIOC_TIMEOUT, &timeout);
I agree that it is simpler than using select.
But just to answer your remark about the posix skin, you can actually
use xenomai posix skin without the "--wrap" trick, and so avoid the
posix skin functions called without wanting it.
What you have to do is use the xenomai posix skin services you want to
use with the __wrap_ prefix. For instance __wrap_socket, __wrap_select.
The simply link with libpthread_rt.so, and do not use the --wrap flag
provided by xeno-config.
--
Gilles.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-07-03 21:44 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-06-28 8:05 [Xenomai] How setup receive-timeout for rt_dev_recvfrom? Henri Roosen
2012-06-28 8:20 ` Gilles Chanteperdrix
2012-07-03 18:08 ` Henri Roosen
2012-07-03 21:44 ` Gilles Chanteperdrix
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.