soem and rtnet

Hi Wim,

On Tue, Jan 8, 2013 at 2:49 AM, Wim Meeussen <wim [..] ...> wrote:
> Hi,
>
> I'm trying to set up a realtime link with an EtherCAT slave, using
> soem and rtnet. My setup looks like this:
> * Ubuntu Precise
> * Xenomai 2.62.
> * 3.2.21 kernel
> * rtnet 0.9.13

We've only tested with Xenomai 2.5.6, 2.6.37 kernel and rtnet 0.9.12,
so hopefully the error you have is not related to any changes between
our and your setup.

> * latest soem from http://git.mech.kuleuven.be/robotics/soem.git,
> which includes the rtnet patch
> (ddefe18325e3e52e6cc48098a71004e83ec56571)
>
> I compiled soem against rtnet/xenomai, and configured the network
> interface using rtifconfig with kernel module rt_e1000e:

We've only tested rt_e1000, but I assume the error you have is not
related to this.

> $ sudo /usr/rtnet/sbin/rtifconfig
> rteth0 Medium: Ethernet Hardware address: 00:0A:9D:10:11:E1
> UP BROADCAST RUNNING MTU: 1500
>

We usually setup rtnet by loading the following rtnet modules:
---
# Protocol stack
sudo insmod ./rtnet.ko
sudo insmod ./rtpacket.ko
sudo insmod ./rtmac.ko
sudo insmod ./rtipv4.ko
sudo insmod ./rtudp.ko
sudo insmod ./rtcfg.ko

# Driver
sudo insmod ./rt_loopback.ko
sudo insmod ./rt_e1000.ko
---
and bring up one of the rtifaces:
---
sudo /usr/local/rtnet/sbin/rtifconfig rteth1 up
---

But I assume you did all of this too.

We also added ourselves to the xenomai group, but again I assume you
did that too.

> Now, I'm trying to run slaveinfo in soem_core, and get the following error:
>
> $ sudo bin/slaveinfo rteth0
> SOEM (Simple Open EtherCAT Master)
> Slaveinfo
> Starting slaveinfo
> getting socket index failed:-1, Operation not permitted
> setting socket timeout failed:-1, Operation not permitted
> resetting socket flags failed:-1, Operation not permitted
> setting socket flags failed:-1, Operation not permitted
> binding socket failed:-1, Operation not permitted
> No socket connection on rteth0
> Excecute as root
> End program
>
> The failure happens in nicdrv.c, line 240:
> /* connect socket to NIC by name */
> strcpy(ifr.ifr_name, ifname);
> r = ioctl(*psock, SIOCGIFINDEX, &ifr);
> if(r<0){
> printf("getting socket index failed:%d, %s\n",r,strerror(-r));
> }
>
>
> Any idea what could be going wrong here? It appears that, no matter
> which interface name I provide, I get the same failure. When I
> compile soem_core without rtnet/xenomai, it correctly communicates
> with the EtherCAT slave.
>
> For full disclosure, I made a small change to the cmake file of
> soem_core, to get around a linking problem (see patch in attachment).

It's actually your patch that indicates the error. We are mixing the
Xenomai posix and native skin in the patched slaveinfo. The soem
library uses the posix skin. By applying your patch we are somehow
overlaying the native skin which results in the behaviour we see (do
not ask me about the actual cause, I'm guessing here).

What we really need to do is not apply your patch but adapt the
slaveinfo executable to not use the native skin. I pushed a verified
fix (2b4fa0cfca3809193) to master.

Ruben

> Thanks,
> Wim
>
>
>
> --
> Wim Meeussen
> CTO, hiDOF Inc.
> 650-529-4522
> http://hidof.com
>
> --
> Orocos-Users mailing list
> Orocos-Users [..] ...
> http://lists.mech.kuleuven.be/mailman/listinfo/orocos-users
>

soem and rtnet

>> I'm trying to set up a realtime link with an EtherCAT slave, using
>> soem and rtnet. My setup looks like this:
>> * Ubuntu Precise
>> * Xenomai 2.62.
>> * 3.2.21 kernel
>> * rtnet 0.9.13
...
> What we really need to do is not apply your patch but adapt the
> slaveinfo executable to not use the native skin. I pushed a verified
> fix (2b4fa0cfca3809193) to master.

First of all, your previous assumptions on how I'm configuring and
running my code are correct (except that I run as root instead of
using a user of the xenomai group).

Your patch definitely solved a number of issues. The program now links
fine, and the execution gets much further. Now I can actually run
'slaveinfo' with rtnet, but the program stops in the middle of the
execution, without any error messages:

$ sudo bin/slaveinfo rteth0
SOEM (Simple Open EtherCAT Master)
Slaveinfo
Starting slaveinfo
ec_init on rteth0 succeeded.

Independent of the code path during execution, there should be other
prints following this output. So something is stopping the execution
of this program. For comparison, when running without rtnet, the
output looks like this with no slaves connected (with slaves
connected, it shows the slave info instead). Note the extra lines
after "ec_init on rteth0 succeeded":

$ sudo bin/slaveinfo eth0
SOEM (Simple Open EtherCAT Master)
Slaveinfo
Starting slaveinfo
ec_init on eth0 succeeded.
No slaves found!
End slaveinfo, close socket
End program

When looking at the network traffic, the rtnet version sends out a
single packet, with an ethercat frame inside. The non-rtnet version
sends out six of those packets, not just one.

It almost looks like Xenomai is terminating my process. Could that
have something to do with mode switches? The slaveinfo code uses
printf in a bunch of places. However, when replacing them with
rt_printf, I get no output at all. The kernel output I get during
execution looks like this:

[ 2761.417922] Xenomai: RTDM: closing file descriptor 0.
[ 2761.417966] Xenomai: Posix: destroying mutex ffffc90011785a00.
[ 2761.417969] Xenomai: Posix: destroying mutex ffffc90011785a80.
[ 2761.417973] Xenomai: Posix: destroying mutex ffffc90011785b00.

Let me know if there is some additional information you'd need. Thanks
for helping out!

Wim

--
Wim Meeussen
CTO, hiDOF Inc.
650-529-4522
http://hidof.com