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) {
224 pt.
hasLink = dl_status.hasLink(i);
225 pt.
isClosed = dl_status.isClosed(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();
307 d.mergeSummaryf(
d.ERROR,
"Device reset likely");
316 d.mergeSummaryf(
d.WARN,
"Have not yet collected diagnostics");
320 d.mergeSummaryf(
d.WARN,
"Could not collect diagnostics");
325 d.mergeSummaryf(
d.WARN,
"No link on port 0");
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());