* [Xenomai] need help to Xenomai Cobalt RTnet socket UDP recvfrom non blocking
@ 2016-06-17 9:55 Laurent LEQUIEVRE
2016-06-17 10:07 ` Gilles Chanteperdrix
0 siblings, 1 reply; 6+ messages in thread
From: Laurent LEQUIEVRE @ 2016-06-17 9:55 UTC (permalink / raw)
To: xenomai@xenomai.org, laurent.lequievre
Hello,
I installed xenomai 3.0.2 and try to test some RTnet features needed for
the communication with my Kuka robot arm.
I specify that I want to work with the skin posix only.
I need to create a UDP socket with a timeout on the 'recvfrom' function
(Non blocking recvfrom).
I tested this first code :
int udp_socket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
bind(udp_socket, ...)
struct timeval timeout;
timeout.tv_sec = 1;
timeout.tv_usec = 0;
setsockopt(udp_socket, SOL_SOCKET, SOCKET_SO_RCVTIMEO, &timeout,
sizeof(timeout));
--> this function return -1, errno=92, Protocol not available ???
....
recvfrom(udp_socket, ....) --> blocked ??
I tested this second code :
int udp_socket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
bind(udp_socket, ...)
fcntl(udp_socket, F_SETFL, O_NONBLOCK);
--> this function return 0
....
recvfrom(udp_socket, ....) --> blocked ??
Can you give me a sample ?
Thanks for your help,
Regards,
Laurent LEQUIEVRE
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Xenomai] need help to Xenomai Cobalt RTnet socket UDP recvfrom non blocking
2016-06-17 9:55 [Xenomai] need help to Xenomai Cobalt RTnet socket UDP recvfrom non blocking Laurent LEQUIEVRE
@ 2016-06-17 10:07 ` Gilles Chanteperdrix
2016-06-17 10:21 ` Gilles Chanteperdrix
2016-06-17 11:28 ` Laurent LEQUIEVRE
0 siblings, 2 replies; 6+ messages in thread
From: Gilles Chanteperdrix @ 2016-06-17 10:07 UTC (permalink / raw)
To: Laurent LEQUIEVRE; +Cc: xenomai@xenomai.org
On Fri, Jun 17, 2016 at 11:55:20AM +0200, Laurent LEQUIEVRE wrote:
> Hello,
>
> I installed xenomai 3.0.2 and try to test some RTnet features needed for
> the communication with my Kuka robot arm.
>
> I specify that I want to work with the skin posix only.
>
> I need to create a UDP socket with a timeout on the 'recvfrom' function
> (Non blocking recvfrom).
>
> I tested this first code :
>
> int udp_socket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
> bind(udp_socket, ...)
> struct timeval timeout;
> timeout.tv_sec = 1;
> timeout.tv_usec = 0;
>
> setsockopt(udp_socket, SOL_SOCKET, SOCKET_SO_RCVTIMEO, &timeout,
> sizeof(timeout));
> --> this function return -1, errno=92, Protocol not available ???
This socket option is not implemented in RTnet sockets. You can use
the RTNET_RTIOC_TIMEOUT ioctl instead.
> ....
> recvfrom(udp_socket, ....) --> blocked ??
>
> I tested this second code :
>
> int udp_socket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
> bind(udp_socket, ...)
> fcntl(udp_socket, F_SETFL, O_NONBLOCK);
> --> this function return 0
> ....
> recvfrom(udp_socket, ....) --> blocked ??
RTnet UDP recvfrom does not check the O_NONBLOCK flag, you can use
recvmsg with MSG_DONTWAIT instead.
--
Gilles.
https://click-hack.org
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Xenomai] need help to Xenomai Cobalt RTnet socket UDP recvfrom non blocking
2016-06-17 10:07 ` Gilles Chanteperdrix
@ 2016-06-17 10:21 ` Gilles Chanteperdrix
2016-06-17 11:28 ` Laurent LEQUIEVRE
1 sibling, 0 replies; 6+ messages in thread
From: Gilles Chanteperdrix @ 2016-06-17 10:21 UTC (permalink / raw)
To: Laurent LEQUIEVRE; +Cc: xenomai@xenomai.org
On Fri, Jun 17, 2016 at 12:07:28PM +0200, Gilles Chanteperdrix wrote:
> On Fri, Jun 17, 2016 at 11:55:20AM +0200, Laurent LEQUIEVRE wrote:
> > Hello,
> >
> > I installed xenomai 3.0.2 and try to test some RTnet features needed for
> > the communication with my Kuka robot arm.
> >
> > I specify that I want to work with the skin posix only.
> >
> > I need to create a UDP socket with a timeout on the 'recvfrom' function
> > (Non blocking recvfrom).
> >
> > I tested this first code :
> >
> > int udp_socket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
> > bind(udp_socket, ...)
> > struct timeval timeout;
> > timeout.tv_sec = 1;
> > timeout.tv_usec = 0;
> >
> > setsockopt(udp_socket, SOL_SOCKET, SOCKET_SO_RCVTIMEO, &timeout,
> > sizeof(timeout));
> > --> this function return -1, errno=92, Protocol not available ???
>
> This socket option is not implemented in RTnet sockets. You can use
> the RTNET_RTIOC_TIMEOUT ioctl instead.
>
>
> > ....
> > recvfrom(udp_socket, ....) --> blocked ??
> >
> > I tested this second code :
> >
> > int udp_socket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
> > bind(udp_socket, ...)
> > fcntl(udp_socket, F_SETFL, O_NONBLOCK);
> > --> this function return 0
> > ....
> > recvfrom(udp_socket, ....) --> blocked ??
>
> RTnet UDP recvfrom does not check the O_NONBLOCK flag, you can use
> recvmsg with MSG_DONTWAIT instead.
You can also use the MSG_DONTWAIT flag in recvfrom.
--
Gilles.
https://click-hack.org
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Xenomai] need help to Xenomai Cobalt RTnet socket UDP recvfrom non blocking
2016-06-17 10:07 ` Gilles Chanteperdrix
2016-06-17 10:21 ` Gilles Chanteperdrix
@ 2016-06-17 11:28 ` Laurent LEQUIEVRE
2016-06-17 13:04 ` laurent LEQUIEVRE
1 sibling, 1 reply; 6+ messages in thread
From: Laurent LEQUIEVRE @ 2016-06-17 11:28 UTC (permalink / raw)
To: Gilles Chanteperdrix; +Cc: Laurent LEQUIEVRE, xenomai@xenomai.org
Hi Gilles,
thank you for your quick answers !
where I can find this option : RTNET_RTIOC_TIMEOUT ?
cd /usr/xenomai_3_0_2/include
grep -r RTNET_RTIOC_TIMEOUT
--> Return nothing
Need to include something in my code ?
Thanks,
Laurent
Le 17/06/2016 12:07, Gilles Chanteperdrix a écrit :
> On Fri, Jun 17, 2016 at 11:55:20AM +0200, Laurent LEQUIEVRE wrote:
>> Hello,
>>
>> I installed xenomai 3.0.2 and try to test some RTnet features needed for
>> the communication with my Kuka robot arm.
>>
>> I specify that I want to work with the skin posix only.
>>
>> I need to create a UDP socket with a timeout on the 'recvfrom' function
>> (Non blocking recvfrom).
>>
>> I tested this first code :
>>
>> int udp_socket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
>> bind(udp_socket, ...)
>> struct timeval timeout;
>> timeout.tv_sec = 1;
>> timeout.tv_usec = 0;
>>
>> setsockopt(udp_socket, SOL_SOCKET, SOCKET_SO_RCVTIMEO, &timeout,
>> sizeof(timeout));
>> --> this function return -1, errno=92, Protocol not available ???
> This socket option is not implemented in RTnet sockets. You can use
> the RTNET_RTIOC_TIMEOUT ioctl instead.
>
>
>> ....
>> recvfrom(udp_socket, ....) --> blocked ??
>>
>> I tested this second code :
>>
>> int udp_socket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
>> bind(udp_socket, ...)
>> fcntl(udp_socket, F_SETFL, O_NONBLOCK);
>> --> this function return 0
>> ....
>> recvfrom(udp_socket, ....) --> blocked ??
> RTnet UDP recvfrom does not check the O_NONBLOCK flag, you can use
> recvmsg with MSG_DONTWAIT instead.
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Xenomai] need help to Xenomai Cobalt RTnet socket UDP recvfrom non blocking
2016-06-17 11:28 ` Laurent LEQUIEVRE
@ 2016-06-17 13:04 ` laurent LEQUIEVRE
2016-06-19 6:45 ` Gilles Chanteperdrix
0 siblings, 1 reply; 6+ messages in thread
From: laurent LEQUIEVRE @ 2016-06-17 13:04 UTC (permalink / raw)
To: Gilles Chanteperdrix; +Cc: laurent.lequievre, xenomai@xenomai.org
Hi Gilles,
It works fine with :
int64_t timeout = 3e09; // 3 seconds to test
int return_ioctl = ioctl(udp_socket,RTNET_RTIOC_TIMEOUT,&timeout);
but it needed to add these 'includes' to compile :
#include <asm/ioctl.h>
#include <rtdm/rtdm.h>
#define RTIOC_TYPE_NETWORK RTDM_CLASS_NETWORK
#define RTNET_RTIOC_TIMEOUT _IOW(RTIOC_TYPE_NETWORK, 0x11, int64_t)
I read in the documentation that rtnet is included in xenomai 3, why there
is no rtnet.h file installed with the xenomai include files ?
Thanks,
Regards,
Laurent LEQUIEVRE
2016-06-17 13:28 GMT+02:00 Laurent LEQUIEVRE <laurent.lequievre@gmail.com>:
> Hi Gilles,
>
> thank you for your quick answers !
>
> where I can find this option : RTNET_RTIOC_TIMEOUT ?
>
> cd /usr/xenomai_3_0_2/include
> grep -r RTNET_RTIOC_TIMEOUT
>
> --> Return nothing
>
> Need to include something in my code ?
>
> Thanks,
>
> Laurent
>
>
>
> Le 17/06/2016 12:07, Gilles Chanteperdrix a écrit :
>
>> On Fri, Jun 17, 2016 at 11:55:20AM +0200, Laurent LEQUIEVRE wrote:
>>
>>> Hello,
>>>
>>> I installed xenomai 3.0.2 and try to test some RTnet features needed for
>>> the communication with my Kuka robot arm.
>>>
>>> I specify that I want to work with the skin posix only.
>>>
>>> I need to create a UDP socket with a timeout on the 'recvfrom' function
>>> (Non blocking recvfrom).
>>>
>>> I tested this first code :
>>>
>>> int udp_socket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
>>> bind(udp_socket, ...)
>>> struct timeval timeout;
>>> timeout.tv_sec = 1;
>>> timeout.tv_usec = 0;
>>>
>>> setsockopt(udp_socket, SOL_SOCKET, SOCKET_SO_RCVTIMEO, &timeout,
>>> sizeof(timeout));
>>> --> this function return -1, errno=92, Protocol not available ???
>>>
>> This socket option is not implemented in RTnet sockets. You can use
>> the RTNET_RTIOC_TIMEOUT ioctl instead.
>>
>>
>> ....
>>> recvfrom(udp_socket, ....) --> blocked ??
>>>
>>> I tested this second code :
>>>
>>> int udp_socket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
>>> bind(udp_socket, ...)
>>> fcntl(udp_socket, F_SETFL, O_NONBLOCK);
>>> --> this function return 0
>>> ....
>>> recvfrom(udp_socket, ....) --> blocked ??
>>>
>> RTnet UDP recvfrom does not check the O_NONBLOCK flag, you can use
>> recvmsg with MSG_DONTWAIT instead.
>>
>>
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Xenomai] need help to Xenomai Cobalt RTnet socket UDP recvfrom non blocking
2016-06-17 13:04 ` laurent LEQUIEVRE
@ 2016-06-19 6:45 ` Gilles Chanteperdrix
0 siblings, 0 replies; 6+ messages in thread
From: Gilles Chanteperdrix @ 2016-06-19 6:45 UTC (permalink / raw)
To: laurent LEQUIEVRE; +Cc: laurent.lequievre, xenomai@xenomai.org
On Fri, Jun 17, 2016 at 03:04:54PM +0200, laurent LEQUIEVRE wrote:
> Hi Gilles,
>
> It works fine with :
> int64_t timeout = 3e09; // 3 seconds to test
> int return_ioctl = ioctl(udp_socket,RTNET_RTIOC_TIMEOUT,&timeout);
>
> but it needed to add these 'includes' to compile :
> #include <asm/ioctl.h>
> #include <rtdm/rtdm.h>
> #define RTIOC_TYPE_NETWORK RTDM_CLASS_NETWORK
> #define RTNET_RTIOC_TIMEOUT _IOW(RTIOC_TYPE_NETWORK, 0x11, int64_t)
>
> I read in the documentation that rtnet is included in xenomai 3, why there
> is no rtnet.h file installed with the xenomai include files
I simply forgot that part. I have used the headers for programs in
Xenomai sources only, where the headers are available. This needs a
cleanup, as the headers mix kernel and user declarations, and in
3.x, the RTDM drivers headers no longer start with rt. So rtnet.h
would probably become rtdm/net.h, and some part of it would have to
move to rtdm/uapi/net.h.
--
Gilles.
https://click-hack.org
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2016-06-19 6:45 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-06-17 9:55 [Xenomai] need help to Xenomai Cobalt RTnet socket UDP recvfrom non blocking Laurent LEQUIEVRE
2016-06-17 10:07 ` Gilles Chanteperdrix
2016-06-17 10:21 ` Gilles Chanteperdrix
2016-06-17 11:28 ` Laurent LEQUIEVRE
2016-06-17 13:04 ` laurent LEQUIEVRE
2016-06-19 6:45 ` 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.