libethercat - an embeddable realtime EtherCAT-master library
Communicate with EtherCAT slaves attached to a Network interface.
|
This library provides all functionality to communicate with EtherCAT slaves attached to a Network interface.
SOCK_RAW
). Therefor the program must either be run as root or with the capability flag CAP_NET_RAW
. Either do sth like: sudo setcap cap_net_raw=ep .libs/example_with_dc
or checkout grant_cap_net_raw kernel module from Flo Schmidt (https://gitlab.com/fastflo/open_ethercat).This software was developed and made available to the public by the Institute of Robotics and Mechatronics of the German Aerospace Center (DLR).
Please note that the use of the EtherCAT technology, the EtherCAT brand name and the EtherCAT logo is only permitted if the property rights of Beckhoff Automation GmbH are observed. For further information please contact Beckhoff Automation GmbH & Co. KG, Hülshorstweg 20, D-33415 Verl, Germany (www.beckhoff.com) or the EtherCAT Technology Group, Ostendstraße 196, D-90482 Nuremberg, Germany (ETG, www.ethercat.org).
See INTRODUCTION.md or gh-pages for reference.
libethercat
uses autotools as build system.
Ensure that libosal
is installed in your system. You can get libosal
from here https://github.com/robert-burger/libosal.git . To build libethercat
from source execute something like:
This will build and install a static as well as a dynamic library. For use in other project you can use the generated pkg-config file to retreave cflags and linker flags.
Steps to build:
Parameter | Default | Description |
---|---|---|
CMAKE_PREFIX_PATH | Install directory of the libosal | |
ECAT_DEVICE | sock_raw | List of EtherCAT devices as + separated list. Possible values: sock_raw+sock_raw_mmaped+file+pikeos+bpf |
BUILD_SHARED_LIBS | OFF | Flag to build shared libraries instead of static ones. |
MBX_SUPPORT_COE | ON | Flag to enable or disable Mailbox CoE support |
MBX_SUPPORT_FOE | ON | Flag to enable or disable Mailbox FoE support |
MBX_SUPPORT_SOE | ON | Flag to enable or disable Mailbox SoE support |
MBX_SUPPORT_EOE | ON | Flag to enable or disable Mailbox EoE support |
libethercat also provides some small helper programs for the EtherCAT bus.
With eepromtool you can read and write EtherCAT slave's eeprom.
To do a read operation simply run:
eepromtool -i eth1 -s 0 -r -f eeprom.bin
If no filename if specified, eepromtool will print the contents to stdout, which you can pipe to hexdump for example.
eepromtool -i eth1 -s 0 -r | hexdump -v -C | less -S
To do a write operation simply run:
eepromtool -i eth1 -s 0 -w -f eeprom.bin
If no filename if specified, eepromtool will read from stdin.
cat eeprom.bin | eepromtool -i eth1 -s 0 -w
This is a more complex example on how to use libethercat in realtime/control systems.
It tries to do the following: