ethercat_driver_ros2  main
C++ ROS test
Classes | Public Types | Public Member Functions | Static Public Member Functions | List of all members
ethercat_interface::EcMaster Class Reference

#include <ec_master.hpp>

Public Types

typedef void(* SIMPLECAT_CONTRL_CALLBACK) (void)
 
typedef void(* SIMPLECAT_EXIT_CALLBACK) (int)
 

Public Member Functions

 EcMaster (const int master=0)
 
virtual ~EcMaster ()
 
void addSlave (uint16_t alias, uint16_t position, EcSlave *slave)
 add a slave device to the master alias and position can be found by running the following command /opt/etherlab/bin$ sudo ./ethercat slaves look for the "A B:C STATUS DEVICE" (e.g. B=alias, C=position) More...
 
int configSlaveSdo (uint16_t slave_position, SdoConfigEntry sdo_config, uint32_t *abort_code)
 configure slave using SDO More...
 
bool activate ()
 
virtual void update (uint32_t domain=0)
 
virtual void run (SIMPLECAT_CONTRL_CALLBACK user_callback)
 
virtual void stop ()
 
virtual double elapsedTime ()
 
virtual uint64_t elapsedCycles ()
 
void setCtrlFrequency (double frequency)
 
uint32_t getInterval ()
 
void readData (uint32_t domain=0)
 
void writeData (uint32_t domain=0)
 

Static Public Member Functions

static void setCtrlCHandler (SIMPLECAT_EXIT_CALLBACK user_callback=NULL)
 
static void setThreadHighPriority ()
 
static void setThreadRealTime ()
 

Member Typedef Documentation

◆ SIMPLECAT_CONTRL_CALLBACK

typedef void(* ethercat_interface::EcMaster::SIMPLECAT_CONTRL_CALLBACK) (void)

run a control loop of update() and user_callback(), blocking. call activate and setThreadHighPriority/RealTime first.

◆ SIMPLECAT_EXIT_CALLBACK

typedef void(* ethercat_interface::EcMaster::SIMPLECAT_EXIT_CALLBACK) (int)

add ctr-c exit callback. default exits the run loop and prints timing

Constructor & Destructor Documentation

◆ EcMaster()

ethercat_interface::EcMaster::EcMaster ( const int  master = 0)
explicit

◆ ~EcMaster()

virtual ethercat_interface::EcMaster::~EcMaster ( )
virtual

Member Function Documentation

◆ addSlave()

void ethercat_interface::EcMaster::addSlave ( uint16_t  alias,
uint16_t  position,
EcSlave slave 
)

add a slave device to the master alias and position can be found by running the following command /opt/etherlab/bin$ sudo ./ethercat slaves look for the "A B:C STATUS DEVICE" (e.g. B=alias, C=position)

◆ configSlaveSdo()

int ethercat_interface::EcMaster::configSlaveSdo ( uint16_t  slave_position,
SdoConfigEntry  sdo_config,
uint32_t *  abort_code 
)

configure slave using SDO

◆ activate()

bool ethercat_interface::EcMaster::activate ( )

call after adding all slaves, and before update

◆ update()

virtual void ethercat_interface::EcMaster::update ( uint32_t  domain = 0)
virtual

perform one EtherCAT cycle, passing the domain to the slaves

◆ run()

virtual void ethercat_interface::EcMaster::run ( SIMPLECAT_CONTRL_CALLBACK  user_callback)
virtual

◆ stop()

virtual void ethercat_interface::EcMaster::stop ( )
inlinevirtual

stop the control loop. use within callback, or from a separate thread.

◆ elapsedTime()

virtual double ethercat_interface::EcMaster::elapsedTime ( )
virtual

time of last ethercat update, since calling run. stops if stop called. returns actual time. use elapsedCycles()/frequency for discrete time at last update.

◆ elapsedCycles()

virtual uint64_t ethercat_interface::EcMaster::elapsedCycles ( )
virtual

number of EtherCAT updates since calling run.

◆ setCtrlCHandler()

static void ethercat_interface::EcMaster::setCtrlCHandler ( SIMPLECAT_EXIT_CALLBACK  user_callback = NULL)
static

◆ setThreadHighPriority()

static void ethercat_interface::EcMaster::setThreadHighPriority ( )
static

set the thread to a priority of -19 priority range is -20 (highest) to 19 (lowest)

◆ setThreadRealTime()

static void ethercat_interface::EcMaster::setThreadRealTime ( )
static

set the thread to real time (FIFO) thread cannot be preempted. set priority as 49 (kernel and interrupts are 50)

◆ setCtrlFrequency()

void ethercat_interface::EcMaster::setCtrlFrequency ( double  frequency)
inline

◆ getInterval()

uint32_t ethercat_interface::EcMaster::getInterval ( )
inline

◆ readData()

void ethercat_interface::EcMaster::readData ( uint32_t  domain = 0)

◆ writeData()

void ethercat_interface::EcMaster::writeData ( uint32_t  domain = 0)

The documentation for this class was generated from the following file: