Class for managing an ethercat bus containing one or multiple slaves.
More...
#include <EthercatBusBase.hpp>
|
bool | addSlave (const EthercatSlaveBasePtr &slave) |
|
bool | busIsAvailable () const |
|
bool | checkForSdoErrors (const uint16_t slave, const uint16_t index) |
|
| EthercatBusBase ()=delete |
|
| EthercatBusBase (const std::string &name) |
|
std::string | getErrorString (ec_errort error) |
|
int | getExpectedWorkingCounter (const uint16_t slave=0) const |
|
PdoSizeMap | getHardwarePdoSizes () |
|
PdoSizePair | getHardwarePdoSizes (const uint16_t slave) |
|
const std::string & | getName () const |
|
int | getNumberOfSlaves () const |
|
const ros::Time & | getUpdateReadStamp () const |
|
const ros::Time & | getUpdateWriteStamp () const |
|
bool | isRunning () |
| Returns if the instance is running. More...
|
|
void | printALStatus (const uint16_t slave=0) |
| Prints application layer status. More...
|
|
template<typename TxPdo > |
void | readTxPdo (const uint16_t slave, TxPdo &txPdo) const |
|
template<typename Value > |
bool | sendSdoRead (const uint16_t slave, const uint16_t index, const uint8_t subindex, const bool completeAccess, Value &value) |
|
template<typename Value > |
bool | sendSdoWrite (const uint16_t slave, const uint16_t index, const uint8_t subindex, const bool completeAccess, const Value value) |
|
void | setState (const uint16_t state, const uint16_t slave=0) |
|
void | shutdown () |
|
bool | startup (const bool sizeCheck=true) |
|
void | syncDistributedClock0 (const uint16_t slave, const bool activate, const double cycleTime, const double cycleShift) |
|
void | updateRead () |
|
void | updateWrite () |
|
bool | waitForState (const uint16_t state, const uint16_t slave=0, const unsigned int maxRetries=40, const double retrySleep=0.001) |
|
bool | workingCounterIsOk () const |
|
int | writeFile (const uint16_t slave, const std::string &fileName, const uint32_t &password, const int fileSize, char *fileBuffer, int timeout=EC_TIMEOUTSTATE *10) |
|
bool | writeFirmware (const uint16_t slave, const std::string &fileName, const uint32_t &password, const int fileSize, char *fileBuffer) |
|
template<typename RxPdo > |
void | writeRxPdo (const uint16_t slave, const RxPdo &rxPdo) |
|
| ~EthercatBusBase ()=default |
|
Class for managing an ethercat bus containing one or multiple slaves.
Definition at line 29 of file EthercatBusBase.hpp.
rokubimini::soem_interface::EthercatBusBase::EthercatBusBase |
( |
| ) |
|
|
delete |
rokubimini::soem_interface::EthercatBusBase::EthercatBusBase |
( |
const std::string & |
name | ) |
|
|
explicit |
Constructor.
- Parameters
-
name | Name of the bus, e.g. "eth0". |
Definition at line 7 of file EthercatBusBase.cpp.
rokubimini::soem_interface::EthercatBusBase::~EthercatBusBase |
( |
| ) |
|
|
default |
Add an EtherCAT slave. EtherCAT slave.
- Returns
- True if successful.
Definition at line 61 of file EthercatBusBase.cpp.
bool rokubimini::soem_interface::EthercatBusBase::busIsAvailable |
( |
const std::string & |
name | ) |
|
|
static |
Check if a bus is available.
- Parameters
-
- Returns
- True if available.
Definition at line 25 of file EthercatBusBase.cpp.
bool rokubimini::soem_interface::EthercatBusBase::busIsAvailable |
( |
| ) |
const |
Check if this bus is available.
- Returns
- True if available.
Definition at line 50 of file EthercatBusBase.cpp.
bool rokubimini::soem_interface::EthercatBusBase::checkForSdoErrors |
( |
const uint16_t |
slave, |
|
|
const uint16_t |
index |
|
) |
| |
Check if an error for the SDO index of the slave exists.
- Parameters
-
slave | Address of the slave. |
index | Index of the SDO. |
- Returns
- True if an error for the index exists.
Definition at line 395 of file EthercatBusBase.cpp.
std::string rokubimini::soem_interface::EthercatBusBase::getErrorString |
( |
ec_errort |
error | ) |
|
Generate and return the error string.
- Parameters
-
error | EtherCAT error object. |
- Returns
- The error string.
Definition at line 339 of file EthercatBusBase.cpp.
int rokubimini::soem_interface::EthercatBusBase::getExpectedWorkingCounter |
( |
const uint16_t |
slave = 0 | ) |
const |
Get the PDO expected working counter.
- Parameters
-
slave | Address of the slave, 0 for all slaves. |
- Returns
- Expected working counter.
Definition at line 332 of file EthercatBusBase.cpp.
Returns a map of the actually requested PDO sizes (Rx & Tx) This is useful for slaves where the PDO size at startup is unknown This method shall be used after adding the slaves and after executing the "startup" method
- Returns
- std::unordered_map with the addresses and the corresponding Pdo sizes
Definition at line 433 of file EthercatBusBase.cpp.
Returns a pair with the TxPdo and RxPdo sizes for the requested address Overloads the "PdoSizeMap getHardwarePdoSizes()" method.
- Parameters
-
slave | Address of the slave |
- Returns
- std::pair with the rx (first) and tx (second) Pdo sizes
Definition at line 445 of file EthercatBusBase.cpp.
const std::string& rokubimini::soem_interface::EthercatBusBase::getName |
( |
| ) |
const |
|
inline |
int rokubimini::soem_interface::EthercatBusBase::getNumberOfSlaves |
( |
| ) |
const |
Get the number of slaves which were detected on this bus.
- Returns
- Number of slaves.
Definition at line 55 of file EthercatBusBase.cpp.
const ros::Time& rokubimini::soem_interface::EthercatBusBase::getUpdateReadStamp |
( |
| ) |
const |
|
inline |
Get the time of the last successful PDO reading.
- Returns
- Stamp.
Definition at line 60 of file EthercatBusBase.hpp.
const ros::Time& rokubimini::soem_interface::EthercatBusBase::getUpdateWriteStamp |
( |
| ) |
const |
|
inline |
Get the time of the last successful PDO writing.
- Returns
- Stamp.
Definition at line 69 of file EthercatBusBase.hpp.
bool rokubimini::soem_interface::EthercatBusBase::isRunning |
( |
| ) |
|
|
inline |
Returns if the instance is running.
- Returns
- True if the instance is running.
Definition at line 342 of file EthercatBusBase.hpp.
void rokubimini::soem_interface::EthercatBusBase::printALStatus |
( |
const uint16_t |
slave = 0 | ) |
|
Prints application layer status.
- Parameters
-
[in] | slave | Address of the slave, 0 for all slaves. |
Definition at line 385 of file EthercatBusBase.cpp.
void rokubimini::soem_interface::EthercatBusBase::printAvailableBusses |
( |
| ) |
|
|
static |
template<typename TxPdo >
void rokubimini::soem_interface::EthercatBusBase::readTxPdo |
( |
const uint16_t |
slave, |
|
|
TxPdo & |
txPdo |
|
) |
| const |
|
inline |
Read a TxPDO from the buffer.
- Parameters
-
slave | Address of the slave. |
txPdo | Return argument, TxPDO container. |
Definition at line 290 of file EthercatBusBase.hpp.
template<typename Value >
bool rokubimini::soem_interface::EthercatBusBase::sendSdoRead |
( |
const uint16_t |
slave, |
|
|
const uint16_t |
index, |
|
|
const uint8_t |
subindex, |
|
|
const bool |
completeAccess, |
|
|
Value & |
value |
|
) |
| |
|
inline |
Send a reading SDO.
- Parameters
-
slave | Address of the slave. |
index | Index of the SDO. |
subindex | Sub-index of the SDO. |
completeAccess | Access all sub-indices at once. |
value | Return argument, will contain the value which was read. |
- Returns
- True if successful.
Definition at line 241 of file EthercatBusBase.hpp.
template<typename Value >
bool rokubimini::soem_interface::EthercatBusBase::sendSdoWrite |
( |
const uint16_t |
slave, |
|
|
const uint16_t |
index, |
|
|
const uint8_t |
subindex, |
|
|
const bool |
completeAccess, |
|
|
const Value |
value |
|
) |
| |
|
inline |
Send a writing SDO.
- Parameters
-
slave | Address of the slave. |
index | Index of the SDO. |
subindex | Sub-index of the SDO. |
completeAccess | Access all sub-indices at once. |
value | Value to write. |
- Returns
- True if successful.
Definition at line 208 of file EthercatBusBase.hpp.
void rokubimini::soem_interface::EthercatBusBase::setState |
( |
const uint16_t |
state, |
|
|
const uint16_t |
slave = 0 |
|
) |
| |
Set the desired EtherCAT state machine state.
- Parameters
-
state | Desired state. |
slave | Address of the slave, 0 for all slaves. |
Definition at line 302 of file EthercatBusBase.cpp.
void rokubimini::soem_interface::EthercatBusBase::shutdown |
( |
| ) |
|
bool rokubimini::soem_interface::EthercatBusBase::startup |
( |
const bool |
sizeCheck = true | ) |
|
Startup the bus communication.
- Parameters
-
sizeCheck | perform a check of the Rx and Tx Pdo sizes defined in the PdoInfo oject of the slaves |
- Returns
- True if successful.
Definition at line 78 of file EthercatBusBase.cpp.
void rokubimini::soem_interface::EthercatBusBase::syncDistributedClock0 |
( |
const uint16_t |
slave, |
|
|
const bool |
activate, |
|
|
const double |
cycleTime, |
|
|
const double |
cycleShift |
|
) |
| |
Synchronize the distributed clocks.
- Parameters
-
| slave | Address of the slave. |
| activate | True to activate the distr. clock, false to deactivate. |
[in] | timeStep | The time step |
Definition at line 420 of file EthercatBusBase.cpp.
void rokubimini::soem_interface::EthercatBusBase::updateRead |
( |
| ) |
|
Update step 1: Read all PDOs.
Receive the EtherCAT data.
Check the working counter.
Each slave attached to this bus reads its data to the buffer.
Definition at line 220 of file EthercatBusBase.cpp.
void rokubimini::soem_interface::EthercatBusBase::updateWrite |
( |
| ) |
|
Update step 2: Write all PDOs.
Each slave attached to this bus write its data to the buffer.
Send the EtherCAT data.
Definition at line 255 of file EthercatBusBase.cpp.
bool rokubimini::soem_interface::EthercatBusBase::waitForState |
( |
const uint16_t |
state, |
|
|
const uint16_t |
slave = 0 , |
|
|
const unsigned int |
maxRetries = 40 , |
|
|
const double |
retrySleep = 0.001 |
|
) |
| |
Wait for an EtherCAT state machine state to be reached.
- Parameters
-
state | Desired state. |
slave | Address of the slave, 0 for all slaves. |
maxRetries | Maximum number of retries. |
retrySleep | Duration to sleep between the retries. |
- Returns
- True if the state has been reached within the timeout.
Definition at line 311 of file EthercatBusBase.cpp.
bool rokubimini::soem_interface::EthercatBusBase::workingCounterIsOk |
( |
| ) |
const |
Check if the current working counter for all slaves is high enough.
- Returns
- True if the working counter is equal or higher than expected.
Definition at line 415 of file EthercatBusBase.cpp.
int rokubimini::soem_interface::EthercatBusBase::writeFile |
( |
const uint16_t |
slave, |
|
|
const std::string & |
fileName, |
|
|
const uint32_t & |
password, |
|
|
const int |
fileSize, |
|
|
char * |
fileBuffer, |
|
|
int |
timeout = EC_TIMEOUTSTATE * 10 |
|
) |
| |
Write file via FoE. It's blocking.
- Parameters
-
slave | Address of the slave. |
filename | The name of the file that will be written in the slave. |
password | The password for authorization. |
fileSize | The size of the file to write. |
fileBuffer | The buffer having the contents of the file. |
timeout | Timeout per mailbox cycle in us, default is EC_TIMEOUTSTATE * 10 |
- Returns
- Workcounter from last slave response
Definition at line 450 of file EthercatBusBase.cpp.
bool rokubimini::soem_interface::EthercatBusBase::writeFirmware |
( |
const uint16_t |
slave, |
|
|
const std::string & |
fileName, |
|
|
const uint32_t & |
password, |
|
|
const int |
fileSize, |
|
|
char * |
fileBuffer |
|
) |
| |
Writes firmware to a slave.
- Parameters
-
slave | Address of the slave. |
fileName | The name of the file that will be written in the slave. |
password | The password for authorization. |
fileSize | The size of the file to write. |
fileBuffer | The buffer having the contents of the file. |
- Returns
- True if the transfer (FoE) was successful.
Definition at line 457 of file EthercatBusBase.cpp.
template<typename RxPdo >
void rokubimini::soem_interface::EthercatBusBase::writeRxPdo |
( |
const uint16_t |
slave, |
|
|
const RxPdo & |
rxPdo |
|
) |
| |
|
inline |
Write an RxPDO to the buffer.
- Parameters
-
slave | Address of the slave. |
rxPdo | RxPDO container. |
Definition at line 304 of file EthercatBusBase.hpp.
std::recursive_mutex rokubimini::soem_interface::EthercatBusBase::contextMutex_ |
|
mutableprotected |
const unsigned int rokubimini::soem_interface::EthercatBusBase::ecatConfigMaxRetries_ { 5 } |
|
protected |
const double rokubimini::soem_interface::EthercatBusBase::ecatConfigRetrySleep_ { 1.0 } |
|
protected |
ecx_contextt rokubimini::soem_interface::EthercatBusBase::ecatContext_ |
|
protected |
int64 rokubimini::soem_interface::EthercatBusBase::ecatDcTime_ { 0 } |
|
protected |
ec_eringt rokubimini::soem_interface::EthercatBusBase::ecatEList_ |
|
protected |
boolean rokubimini::soem_interface::EthercatBusBase::ecatError_ { FALSE } |
|
protected |
ec_idxstackT rokubimini::soem_interface::EthercatBusBase::ecatIdxStack_ |
|
protected |
ecx_portt rokubimini::soem_interface::EthercatBusBase::ecatPort_ |
|
protected |
int rokubimini::soem_interface::EthercatBusBase::ecatSlavecount_ { 0 } |
|
protected |
ec_eepromSMt rokubimini::soem_interface::EthercatBusBase::ecatSm_ |
|
protected |
char rokubimini::soem_interface::EthercatBusBase::ioMap_[4096] |
|
protected |
std::atomic<bool> rokubimini::soem_interface::EthercatBusBase::isRunning_ |
|
protected |
std::string rokubimini::soem_interface::EthercatBusBase::name_ |
|
protected |
bool rokubimini::soem_interface::EthercatBusBase::sentProcessData_ { false } |
|
protected |
Bool indicating whether PDO data has been sent and not read yet.
Definition at line 355 of file EthercatBusBase.hpp.
ros::Time rokubimini::soem_interface::EthercatBusBase::updateReadStamp_ |
|
protected |
ros::Time rokubimini::soem_interface::EthercatBusBase::updateWriteStamp_ |
|
protected |
std::atomic<int> rokubimini::soem_interface::EthercatBusBase::wkc_ |
|
protected |
The documentation for this class was generated from the following files: