[etherlab-dev] Problems interfacing C++ application to Igh EtherCAT master

Steffen Dalgard steffen.sint at gmail.com
Fri Apr 5 22:57:36 CEST 2013


Hi,
I am working for a EU founded project named CORBYS (www.corbys.eu)
developing a training device for gait rehabilitation. We plan to use Igh
Ethercat together with OROCOS and ROS running Linux 10.04 for our robotic
system.

I have tested a very basic test application as a C program based on the Igh
examples.
  This works as expected.

I have started to make a C++ framework for an application interfacing to
Igh.
  This is based on my working C test program rewritten into a C++ class
structure.
  The final program is planned to support 15 slavetypes with 50 slaves
instances.

It seems that C++ doesnt like the way ecrt.h does forward referencing of
data structures.

In the file ecrt.h file the structure ec_master is declared as follows:

/******************************************************************************
     * Data types
     *****************************************************************************/
    struct ec_master;
    typedef struct ec_master ec_master_t; /**< \see ec_master */

This is the only declaration of the structure in this header file.
My impression is that the content of the structure is resolved when linking
with the library
    /opt/etherlab/lib/libethercat.a


When including this in my C++ files i am importing ecrt.h in "C-mode"
    extern "C" {
    #include "ecrt.h"
    }
The data structures declared in ecrt.h are used as members in class objects.
    class RtnIf {
    protected:
        ec_master_t *MasterPtr;
When compiling the compiler reports the following error:
    /home/ecmaster/ros_workspace/rtn_test/RTN-master-inc/rtnm_if.h:49:
error: ISO C++ forbids declaration of ‘ec_master_t’ with no type
    /home/ecmaster/ros_workspace/rtn_test/RTN-master-inc/rtnm_if.h:49:
error: expected ‘;’ before ‘*’ token

Do you have experience interfacing Igh to C++?

Currently I have tested this as a user space application.
Do you have experience using C++ in kernel-mode?

I wonder whether there has to be made a set of wrapper functions copying
the data needed into new locally defined data structures.

More details and examples can be added if needed.

Any comments welcome.

Best regards
Steffen Dalgard
SINTEF ICT
Norway
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.etherlab.org/pipermail/etherlab-dev/attachments/20130405/2b3cabb7/attachment.htm>


More information about the etherlab-dev mailing list