39 #include <dll/ethercat_device_addressed_telegram.h>    40 #include <dll/ethercat_logical_addressed_telegram.h>    41 #include <dll/ethercat_frame.h>    51   for (
unsigned i=0; i<4; ++i) {
    69   for (
unsigned i=0; i<4; ++i) {
    84   return status & (1<<(4+port));
    90   return status & (1<<(9+port*2));
    96   return status & (1<<(8+port*2));
   123   errorCountersMayBeCleared_(false),
   124   diagnosticsFirst_(true),
   125   diagnosticsValid_(false),
   126   resetDetected_(false),
   127   devicesRespondingToNodeAddress_(-1)
   148   for (
unsigned i=0; i<4; ++i) {
   174     EC_Logic *logic = EC_Logic::instance();
   176     NPRD_Telegram nprd_telegram(logic->get_idx(),
   177                                 sh->get_station_address(),
   181                                 (
unsigned char*) &dl_status);
   183     unsigned char buf[1];    
   184     EC_UINT address = 0x0000;
   185     APRD_Telegram aprd_telegram(logic->get_idx(),  
   195     nprd_telegram.attach(&aprd_telegram);
   197     EC_Ethernet_Frame frame(&nprd_telegram);
   208       if (aprd_telegram.get_adp() >= EtherCAT_AL::instance()->get_num_slaves()) {
   222     for (
unsigned i=0;i<4;++i) {
   232     assert(
sizeof(e) == (0x314-0x300));
   246       ROS_ERROR(
"Device %d : previous port error counters less current values", sh->get_ring_position());
   279   assert(numPorts > 0);
   286   ostringstream os, port;
   287   for (
unsigned i=0; i<numPorts; ++i) {
   289     port.str(
""); port << 
" Port " << i;
   290     os.str(
""); os << 
"Status" << port.str();
   291     d.
addf(os.str(), 
"%s Link, %s, %s Comm", 
   295     os.str(
""); os << 
"RX Error" << port.str();
   297     os.str(
""); os << 
"Forwarded RX Error" << port.str();
   299     os.str(
""); os << 
"Invalid Frame" << port.str();
   301     os.str(
""); os << 
"Lost Link" << port.str();
   316       d.
mergeSummaryf(d.WARN, 
"Have not yet collected diagnostics");
   351     ROS_FATAL(
"Initializing indexLock failed : %s", strerror(error));
   358     ROS_FATAL(
"Initializing diagnositcsLock failed : %s", strerror(error));
   400   unsigned char *p = (
unsigned char *)buffer;
   401   EC_Logic *logic = EC_Logic::instance();
   403   NPRW_Telegram nprw_telegram(logic->get_idx(),
   404                               sh->get_station_address(),
   410   APRW_Telegram aprw_telegram(logic->get_idx(),  
   411                               -sh->get_ring_position(), 
   418   EC_Telegram * telegram = NULL;
   420     telegram = &nprw_telegram;
   422     telegram = &aprw_telegram;
   429   EC_Ethernet_Frame frame(telegram);
   437   if (telegram->get_wkc() != 3) {
   447   unsigned char *p = (
unsigned char *)buffer;
   448   EC_Logic *logic = EC_Logic::instance();
   450   NPRD_Telegram nprd_telegram(logic->get_idx(),
   451                               sh->get_station_address(),
   457   APRD_Telegram aprd_telegram(logic->get_idx(),  
   458                               -sh->get_ring_position(), 
   465   EC_Telegram * telegram = NULL;
   467     telegram = &nprd_telegram;
   469     telegram = &aprd_telegram;
   476   EC_Ethernet_Frame frame(telegram);
   484   if (telegram->get_wkc() != 1) {
   494   unsigned char const *p = (
unsigned char const*)buffer;
   495   EC_Logic *logic = EC_Logic::instance();
   497   NPWR_Telegram npwr_telegram(logic->get_idx(),
   498                               sh->get_station_address(),
   504   APWR_Telegram apwr_telegram(logic->get_idx(),  
   505                               -sh->get_ring_position(), 
   512   EC_Telegram * telegram = NULL;
   514     telegram = &npwr_telegram;
   516     telegram = &apwr_telegram;
   523   EC_Ethernet_Frame frame(telegram);
   530   if (telegram->get_wkc() != 1) {
   560   str << 
"EtherCAT Device (" << std::setw(2) << std::setfill(
'0') << 
sh_->get_ring_position() << 
")";
   563   str << 
sh_->get_product_code() << 
'-' << 
sh_->get_serial();
   564   d.hardware_id = str.str();
   570   d.
addf(
"Position", 
"%02d", 
sh_->get_ring_position());
   571   d.
addf(
"Product code", 
"%08x", 
sh_->get_product_code());
   572   d.
addf(
"Serial", 
"%08x", 
sh_->get_serial());
   573   d.
addf(
"Revision", 
"%08x", 
sh_->get_revision());
 
static const EC_UINT BASE_ADDR
 
unsigned int command_size_
 
EthercatPortDiagnostics portDiagnostics_[4]
 
bool isClosed(unsigned port)
 
EthercatDeviceDiagnostics()
 
virtual void multiDiagnostics(vector< diagnostic_msgs::DiagnosticStatus > &vec, unsigned char *buffer)
For EtherCAT devices that publish more than one EtherCAT Status message. If sub-class implements mult...
 
void collect(EthercatCom *com, EtherCAT_SlaveHandler *sh)
 
EthercatDeviceDiagnostics deviceDiagnostics[2]
 
void ethercatDiagnostics(diagnostic_updater::DiagnosticStatusWrapper &d, unsigned numPorts)
Adds diagnostic information for EtherCAT ports. 
 
pthread_mutex_t newDiagnosticsIndexLock_
 
et1x00_error_counters errorCountersPrev_
 
unsigned newDiagnosticsIndex_
 
static int writeData(EthercatCom *com, EtherCAT_SlaveHandler *sh, EC_UINT address, void const *buffer, EC_UINT length, AddrMode addrMode)
Write data to device ESC. 
 
diagnostic_updater::DiagnosticStatusWrapper diagnostic_status_
 
static const EC_UINT BASE_ADDR
 
virtual void construct(EtherCAT_SlaveHandler *sh, int &start_address)
< Construct EtherCAT device 
 
void publish(diagnostic_updater::DiagnosticStatusWrapper &d, unsigned numPorts=4) const 
 
void addf(const std::string &key, const char *format,...)
 
bool hasCommunication(unsigned port)
 
bool hasLink(unsigned port)
 
virtual void collectDiagnostics(EthercatCom *com)
 
pthread_mutex_t diagnosticsLock_
 
EthercatPortDiagnostics()
 
bool hasLink(unsigned port)
 
int devicesRespondingToNodeAddress_
 
uint64_t invalidFrameTotal
 
virtual ~EthercatDevice()
 
bool isClosed(unsigned port)
 
static int readWriteData(EthercatCom *com, EtherCAT_SlaveHandler *sh, EC_UINT address, void *buffer, EC_UINT length, AddrMode addrMode)
Read then write data to ESC. 
 
virtual void diagnostics(diagnostic_updater::DiagnosticStatusWrapper &d, unsigned char *buffer)
For EtherCAT device that only publish one EtherCAT Status message. If sub-class implements multiDiagn...
 
virtual bool txandrx_once(struct EtherCAT_Frame *frame)=0
 
EtherCAT_SlaveHandler * sh_
 
void accumulate(const et1x00_error_counters &next, const et1x00_error_counters &prev)
 
bool hasCommunication(unsigned port)
 
uint64_t forwardedRxErrorTotal
 
static int readData(EthercatCom *com, EtherCAT_SlaveHandler *sh, EC_UINT address, void *buffer, EC_UINT length, AddrMode addrMode)
Read data from device ESC. 
 
uint8_t forwarded_rx_error[4]
 
unsigned int status_size_
 
void mergeSummaryf(unsigned char lvl, const char *format,...)
 
bool isGreaterThan(unsigned value) const 
 
bool errorCountersMayBeCleared_
 
virtual bool txandrx(struct EtherCAT_Frame *frame)=0