need help to Xenomai Cobalt RTnet socket UDP recvfrom non blocking
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
Quoted 18 lines · 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;
Quoted 3 lines
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.
Quoted 11 lines
....
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.
Signature · 2 lines
Gilles. https://click-hack.org
Quoted 39 lines · Gilles Chanteperdrix
Quoted 18 lines · 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;Quoted 3 lines
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_TIMEOUTioctl instead.Quoted 11 lines
....
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 ??
Quoted 2 lines
RTnet UDP recvfrom does not check the
O_NONBLOCKflag, you can use recvmsg withMSG_DONTWAITinstead.
You can also use the MSG_DONTWAIT flag in recvfrom.
Signature · 2 lines
Gilles. https://click-hack.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
Quoted 40 lines · Gilles Chanteperdrix
Quoted 18 lines · 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;Quoted 3 lines
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_TIMEOUTioctl instead.Quoted 11 lines
....
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_NONBLOCKflag, you can use recvmsg withMSG_DONTWAITinstead.
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 <[email protected]>:
Quoted 66 lines
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 -rRTNET_RTIOC_TIMEOUT--> Return nothing
Need to include something in my code ?
Thanks,
Laurent
Quoted 44 lines · Gilles Chanteperdrix
Quoted 18 lines · 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;Quoted 4 lines
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_TIMEOUTioctl instead.....
Quoted 11 lines
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_NONBLOCKflag, you can use recvmsg withMSG_DONTWAITinstead.
Quoted 6 lines · laurent LEQUIEVRE
Hi Gilles,
It works fine with :
int64_ttimeout = 3e09; // 3 seconds to test
intreturn_ioctl=ioctl(udp_socket,RTNET_RTIOC_TIMEOUT,&timeout);
Quoted 8 lines
but it needed to add these 'includes' to compile :
#include <asm/ioctl.h>
#include <rtdm/rtdm.h>
#defineRTIOC_TYPE_NETWORKRTDM_CLASS_NETWORK
#defineRTNET_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.hfile 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.
Signature · 2 lines
Gilles. https://click-hack.org