Using Orocos slave activities to implement a SOEM/Ethercat master [shared memory between 2 tasks]

Hi all,
I have installed SOEM as a system library and I had use it to compile
and execute some simple programs in C.
Now I'm using SOEM with Orocos and I have two tasks. The first one is
the master and the second one the slave.
Using Orocos syntax I have obtained that the master's task executes,
with its own thread, the slave's task.
For this reason I can give to the slave a memory pointer so that the
slave can (using the master thread) write/read directly to/from
ec_slave[1].outputs/inputs.
[Note: ec_slave structure is a structure declared in the SOEM library
and initialized by the master but using the pointer I can write in it
from the updatehook of the slave]

Using this structure I can correctly run the components to find the
slaves and configure.
I use the configurehook of the master to call the configurehook of the
slavesto set the PDO mapping and other settings by SDO.
The problems arise when I execute the updatehook of the master that
calls the updatehook of the slave.

When I start to use PDOs(in operational state, after a correct and
verified PDO mapping) happens something strange.

1)Compiling and running no warnings or errors appear but during the
updatehook PDOs doesn't arrive to the slaves.

2)If I put an SDOread at the beginning of the updatehook the output
PDOs start working well.
Anyway the input PDOs from the slaves continue to be 0.

Anyone has an idea of why using an SDOread I can obtain that the PDOs
output start working?
Can it be a problem of shared memory between 2 tasks, even if executed
with the same thread?
And why even if the outputs are working the input PDO (PDO arriving
from the slaves) continue to be 0 or unreadable?

Thanks for any hint

Luca

Ruben Smits's picture

Using Orocos slave activities to implement a SOEM/Ethercat maste

On Wed, May 16, 2012 at 7:32 PM, Luca Magnabosco
<magnabosco [dot] luca [..] ...> wrote:
> Hi all,
> I have installed SOEM as a system library and I had use it to compile
> and execute some simple programs in C.
> Now I'm using SOEM with Orocos and I have two tasks. The first one is
> the master and the second one the slave.
> Using Orocos syntax I have obtained that the master's task executes,
> with its own thread, the slave's task.
> For this reason I can give to the slave a memory pointer so that the
> slave can (using the master thread) write/read directly to/from
> ec_slave[1].outputs/inputs.
> [Note: ec_slave structure is a structure declared in the SOEM library
> and initialized by the master but using the pointer I can write in it
> from the updatehook of the slave]
>
> Using this structure I can correctly run the components to find the
> slaves and configure.
> I use the configurehook of the master to call the configurehook of the
> slavesto set the PDO mapping and other settings by SDO.
> The problems arise when I execute the updatehook of the master that
> calls the updatehook of the slave.

Which version of the soem_master are you using? There was a bug solved
recently that makes sure that the IOmap is created after the
configuration of the slaves.

>
> When I start to use PDOs(in operational state, after a correct and
> verified PDO mapping)  happens something strange.
>
> 1)Compiling and running no warnings or errors appear but during the
> updatehook PDOs doesn't arrive to the slaves.
>
> 2)If I put an SDOread at the beginning of the updatehook the output
> PDOs start working well.
>   Anyway the input PDOs from  the slaves continue to be 0.
>
> Anyone has an idea of why using an SDOread I can obtain that the PDOs
> output start working?
> Can it be a problem of shared memory between 2 tasks, even if executed
> with the same thread?
> And why even if the outputs are working the input PDO (PDO arriving
> from the slaves) continue to be 0 or unreadable?

Have you already tried without the 2 tasks. Can you verify that the
problem only occurs in this case and that it works perfectly if
everything is running in a single task?

> Thanks for any hint
>
> Luca

Best Regards,

Ruben