13 #include <yarp/os/Time.h>
14 #include <yarp/os/Network.h>
15 #include <yarp/conf/environment.h>
16 #include <yarp/os/NetType.h>
19 #include "EOropframe_hid.h"
21 #include "EoProtocol.h"
22 #include "EoManagement.h"
23 #include "EoProtocolMN.h"
26 using namespace yarp::os;
27 using namespace yarp::os::impl;
39 EthResource::EthResource()
42 isInRunningMode =
false;
44 verifiedBoardPresence =
false;
45 askedBoardVersion =
false;
46 verifiedBoardTransceiver =
false;
48 cleanedBoardBehaviour =
false;
50 boardMNprotocolversion.major = boardMNprotocolversion.minor;
53 txconfig.cycletime = defcycletime;
54 txconfig.txratedivider = defTXrateOfRegularROPs;
55 txconfig.maxtimeRX = defmaxtimeRX;
56 txconfig.maxtimeDO = defmaxtimeDO;
57 txconfig.maxtimeTX = defmaxtimeTX;
58 txconfig.logging.flags = (0x0001 << eomn_appl_log_asynchro_exectime_overflow);
59 txconfig.logging.period10ms = 0;
61 memset(verifiedEPprotocol, 0,
sizeof(verifiedEPprotocol));
63 usedNumberOfRegularROPs = 0;
65 for(
int i = 0; i<16; i++)
67 c_string_handler[i] = NULL;
70 std::string
tmp = yarp::conf::environment::get_string(
"ETH_VERBOSEWHENOK");
73 verbosewhenok = (bool)(yarp::conf::numeric::from_string(
tmp, 0U));
77 verbosewhenok =
false;
82 regularsAreSet =
false;
86 EthResource::~EthResource()
91 for(
int i=0; i<16; i++)
93 if (c_string_handler[i] != NULL)
95 delete c_string_handler[i];
96 c_string_handler[i] = NULL;
101 bool EthResource::lock(
bool on)
112 bool EthResource::open2(eOipv4addr_t remIP, yarp::os::Searchable &cfgtotal)
127 properties.ipv4addr = remIP;
134 properties.txROPratedivider = txconfig.txratedivider;
153 eOipv4addressing_t localIPv4 = ethManager->getLocalIPV4addressing();
156 if(
false == transceiver.init2(
this, cfgtotal, localIPv4, remIP))
158 yError() <<
"EthResource::open2() cannot init transceiver w/ HostTransceiver::init2() for BOARD" << properties.boardnameString <<
"IP" << properties.ipv4addrString;
165 monitorpresence.config(mpConfig);
166 monitorpresence.tick();
176 bool EthResource::close()
183 const void * EthResource::getUDPtransmit(eOipv4addressing_t &destination,
size_t &sizeofpacket, uint16_t &numofrops)
185 destination = properties.ipv4addressing;
186 const void * udp = transceiver.getUDP(sizeofpacket, numofrops);
203 bool EthResource::Tick()
205 monitorpresence.tick();
210 bool EthResource::Check()
212 if(
false == regularsAreSet)
217 return monitorpresence.check();
222 bool EthResource::processRXpacket(
const void *
data,
const size_t size)
224 return transceiver.parseUDP(
data, size);
242 bool EthResource::isRunning(
void)
244 return(isInRunningMode);
249 bool EthResource::verifyBoardTransceiver()
253 if(verifiedBoardTransceiver)
259 #define DONT_ASK_COMM_STATUS
261 #if defined(DONT_ASK_COMM_STATUS)
263 const eoprot_version_t * pc104versionMN = eoprot_version_of_endpoint_get(eoprot_endpoint_management);
264 const eoprot_version_t * brdversionMN = &boardMNprotocolversion;
273 const eoprot_version_t * pc104versionMN = eoprot_version_of_endpoint_get(eoprot_endpoint_management);
274 const double timeout = 0.100;
276 eOprotID32_t id32 = eoprot_ID_get(eoprot_endpoint_management, eoprot_entity_mn_comm, 0, eoprot_tag_mn_comm_status);
277 eOmn_comm_status_t brdstatus = {0};
280 bool rr = nvman.
ask(ipv4addr, id32, &brdstatus, timeout);
284 yError() <<
"EthResource::verifyBoardTransceiver() cannot read brdstatus w/ theNVmanager for BOARD" << getProperties().boardnameString <<
"with IP" << getProperties().ipv4addrString <<
": cannot proceed any further";
288 eoprot_version_t * brdversionMN = (eoprot_version_t*)&brdstatus.managementprotocolversion;
292 if(pc104versionMN->major != brdversionMN->major)
294 yError() <<
"EthResource::verifyBoardTransceiver() detected different mn protocol major versions: local =" << pc104versionMN->major <<
", remote =" << brdversionMN->major <<
": cannot proceed any further";
295 yError() <<
"ACTION REQUIRED: BOARD" << getProperties().boardnameString <<
"with IP" << getProperties().ipv4addrString <<
"needs a FW update.";
299 if(pc104versionMN->minor != brdversionMN->minor)
301 yError() <<
"EthResource::verifyBoardTransceiver() detected different mn protocol minor versions: local =" << pc104versionMN->minor <<
", remote =" << brdversionMN->minor <<
": cannot proceed any further.";
302 yError() <<
"ACTION REQUIRED: BOARD" << getProperties().boardnameString <<
"with IP" << getProperties().ipv4addrString <<
"needs a FW update.";
309 yDebug() <<
"EthResource::verifyBoardTransceiver() has validated the transceiver of BOARD" << getProperties().boardnameString <<
"with IP" << getProperties().ipv4addrString;
312 verifiedBoardTransceiver =
true;
319 bool EthResource::setTimingOfRunningCycle()
332 eOprotID32_t id32 = eoprot_ID_get(eoprot_endpoint_management, eoprot_entity_mn_appl, 0, eoprot_tag_mn_appl_config);
336 if(
false == nvman.
setcheck(properties.ipv4addr, id32, &txconfig, 5, 0.010, 2.0))
338 yWarning() <<
"EthResource::setTimingOfRunningCycle() for BOARD" << getProperties().boardnameString <<
"with IP" << getProperties().ipv4addrString <<
"could not configure: cycletime =" << txconfig.cycletime <<
"usec, RX DO TX = (" << txconfig.maxtimeRX << txconfig.maxtimeDO << txconfig.maxtimeTX <<
") usec and TX rate =" << txconfig.txratedivider <<
" every cycle";
345 yDebug() <<
"EthResource::setTimingOfRunningCycle() for BOARD" << getProperties().boardnameString <<
"with IP" << getProperties().ipv4addrString <<
"has succesfully set: cycletime =" << txconfig.cycletime <<
"usec, RX DO TX = (" << txconfig.maxtimeRX << txconfig.maxtimeDO << txconfig.maxtimeTX <<
") usec and TX rate =" << txconfig.txratedivider <<
" every cycle";
356 bool EthResource::cleanBoardBehaviour(
void)
358 if(cleanedBoardBehaviour)
364 if(
false == serviceStop(eomn_serv_category_all))
366 yError() <<
"EthResource::cleanBoardBehaviour() cannot stop services for BOARD" << getProperties().boardnameString <<
"with IP" << getProperties().ipv4addrString <<
": cannot proceed any further";
370 regularsAreSet =
false;
375 yDebug() <<
"EthResource::cleanBoardBehaviour() has cleaned the application in BOARD" << getProperties().boardnameString <<
"with IP" << getProperties().ipv4addrString <<
": config mode + cleared all its regulars";
378 cleanedBoardBehaviour =
true;
384 bool EthResource::testMultipleASK()
392 eOprotID32_t id32_commstatus = eoprot_ID_get(eoprot_endpoint_management, eoprot_entity_mn_comm, 0, eoprot_tag_mn_comm_status);
393 eOmn_comm_status_t value_commstatus = {0};
395 eOprotID32_t id32_applconfig = eoprot_ID_get(eoprot_endpoint_management, eoprot_entity_mn_appl, 0, eoprot_tag_mn_appl_config);
396 eOmn_appl_config_t value_applconfig = {0};
398 eOprotID32_t id32_applconfig_txratedivider = eoprot_ID_get(eoprot_endpoint_management, eoprot_entity_mn_appl, 0, eoprot_tag_mn_appl_config_txratedivider);
399 uint8_t txratedivider = 0;
401 std::vector<eOprotID32_t> id32s;
402 std::vector<void*> values;
404 id32s.push_back(id32_commstatus);
405 values.push_back(&value_commstatus);
407 id32s.push_back(id32_applconfig);
408 values.push_back(&value_applconfig);
410 id32s.push_back(id32_applconfig_txratedivider);
411 values.push_back(&txratedivider);
413 id32s.push_back(id32_applconfig_txratedivider);
414 values.push_back(&txratedivider);
416 id32s.push_back(id32_applconfig_txratedivider);
417 values.push_back(&txratedivider);
419 id32s.push_back(id32_applconfig_txratedivider);
420 values.push_back(&txratedivider);
422 id32s.push_back(id32_applconfig_txratedivider);
423 values.push_back(&txratedivider);
425 id32s.push_back(id32_applconfig_txratedivider);
426 values.push_back(&txratedivider);
428 id32s.push_back(id32_applconfig_txratedivider);
429 values.push_back(&txratedivider);
431 id32s.push_back(id32_applconfig_txratedivider);
432 values.push_back(&txratedivider);
436 double tprev = SystemClock::nowSystem();
437 double tcurr = SystemClock::nowSystem();
439 double delta = tcurr - tprev;
441 yDebug() <<
"before";
442 yDebug() <<
"value_commstatus.managementprotocolversion.major = " << value_commstatus.managementprotocolversion.major <<
"value_commstatus.managementprotocolversion.minor = " << value_commstatus.managementprotocolversion.minor;
443 yDebug() <<
"value_applconfig.cycletime = " << value_applconfig.cycletime <<
"value_applconfig.txratedivider" << value_applconfig.txratedivider <<
"etc";
444 yDebug() <<
"txratedivider = " << txratedivider;
446 tprev = SystemClock::nowSystem();
448 bool ok = getRemoteValues(id32s, values, 3.0);
449 delta = SystemClock::nowSystem() - tprev;
451 yDebug() <<
"parallel mode: after" << delta <<
"seconds";
452 yDebug() <<
"value_commstatus.managementprotocolversion.major = " << value_commstatus.managementprotocolversion.major <<
"value_commstatus.managementprotocolversion.minor = " << value_commstatus.managementprotocolversion.minor;
453 yDebug() <<
"value_applconfig.cycletime = " << value_applconfig.cycletime <<
"value_applconfig.txratedivider" << value_applconfig.txratedivider <<
"etc";
454 yDebug() <<
"txratedivider = " << txratedivider;
456 memset(&value_commstatus, 0,
sizeof(value_commstatus));
457 memset(&value_applconfig, 0,
sizeof(value_applconfig));
461 tprev = SystemClock::nowSystem();
462 nvman.
ask(&transceiver, id32_commstatus, &value_commstatus, 3.0);
463 nvman.
ask(&transceiver, id32_applconfig, &value_applconfig, 3.0);
464 nvman.
ask(&transceiver, id32_applconfig_txratedivider, &txratedivider, 3.0);
465 nvman.
ask(&transceiver, id32_applconfig_txratedivider, &txratedivider, 3.0);
466 nvman.
ask(&transceiver, id32_applconfig_txratedivider, &txratedivider, 3.0);
467 nvman.
ask(&transceiver, id32_applconfig_txratedivider, &txratedivider, 3.0);
468 nvman.
ask(&transceiver, id32_applconfig_txratedivider, &txratedivider, 3.0);
469 nvman.
ask(&transceiver, id32_applconfig_txratedivider, &txratedivider, 3.0);
470 nvman.
ask(&transceiver, id32_applconfig_txratedivider, &txratedivider, 3.0);
471 nvman.
ask(&transceiver, id32_applconfig_txratedivider, &txratedivider, 3.0);
472 delta = SystemClock::nowSystem() - tprev;
474 yDebug() <<
"serial mode: after" << delta <<
"seconds";
475 yDebug() <<
"value_commstatus.managementprotocolversion.major = " << value_commstatus.managementprotocolversion.major <<
"value_commstatus.managementprotocolversion.minor = " << value_commstatus.managementprotocolversion.minor;
476 yDebug() <<
"value_applconfig.cycletime = " << value_applconfig.cycletime <<
"value_applconfig.txratedivider" << value_applconfig.txratedivider <<
"etc";
477 yDebug() <<
"txratedivider = " << txratedivider;
487 bool EthResource::verifyEPprotocol(eOprot_endpoint_t ep)
489 if((uint8_t)ep >= eoprot_endpoints_numberof)
491 yError() <<
"EthResource::verifyEPprotocol() called with wrong ep = " << ep <<
": cannot proceed any further";
495 if(
true == verifiedEPprotocol[ep])
500 if(
false == verifyBoard())
502 yError() <<
"EthResource::verifyEPprotocol() cannot verify BOARD" << getProperties().boardnameString <<
"with IP" << getProperties().ipv4addrString <<
": cannot proceed any further";
506 if(
false == askBoardVersion())
508 yError() <<
"EthResource::verifyEPprotocol() cannot ask the version to BOARD" << getProperties().boardnameString <<
"with IP" << getProperties().ipv4addrString <<
": cannot proceed any further";
521 const double timeout = 0.100;
523 eOprotID32_t id2send = eo_prot_ID32dummy;
524 eOprotID32_t id2wait = eo_prot_ID32dummy;
525 eOmn_command_t command = {0};
529 id2send = eoprot_ID_get(eoprot_endpoint_management, eoprot_entity_mn_comm, 0, eoprot_tag_mn_comm_cmmnds_command_queryarray);
530 memset(&command, 0,
sizeof(command));
531 command.cmd.opc = eomn_opc_query_array_EPdes;
532 command.cmd.queryarray.opcpar.opc = eomn_opc_query_array_EPdes;
533 command.cmd.queryarray.opcpar.endpoint = eoprot_endpoint_all;
534 command.cmd.queryarray.opcpar.setnumber = 0;
535 command.cmd.queryarray.opcpar.setsize = 0;
538 id2wait = eoprot_ID_get(eoprot_endpoint_management, eoprot_entity_mn_comm, 0, eoprot_tag_mn_comm_cmmnds_command_replyarray);
542 if(
false == nvman.
command(properties.ipv4addr, id2send, &command, id2wait, &command, timeout))
544 yError() <<
"EthResource::verifyEPprotocol() retrieve the endpoint descriptors from BOARD" << getProperties().boardnameString <<
"with IP" << getProperties().ipv4addrString <<
": cannot proceed any further";
549 eOmn_cmd_replyarray_t* cmdreplyarray = (eOmn_cmd_replyarray_t*)&command.cmd.replyarray;
550 EOarray* array = (EOarray*)cmdreplyarray->array;
553 uint8_t sizeofarray = eo_array_Size(array);
556 for(
int i=0; i<sizeofarray; i++)
558 eoprot_endpoint_descriptor_t *epd = (eoprot_endpoint_descriptor_t*)eo_array_At(array, i);
560 if(epd->endpoint == eoprot_endpoint_management)
562 const eoprot_version_t * pc104versionMN = eoprot_version_of_endpoint_get(eoprot_endpoint_management);
563 if(pc104versionMN->major != epd->version.major)
565 yError() <<
"EthResource::verifyEPprotocol() for ep =" << eoprot_EP2string(epd->endpoint) <<
"detected: pc104.version.major =" << pc104versionMN->major <<
"and board.version.major =" << epd->version.major;
566 yError() <<
"EthResource::verifyEPprotocol() detected mismatching protocol version.major in BOARD" << getProperties().boardnameString <<
"with IP" << getProperties().ipv4addrString <<
"for eoprot_endpoint_management: cannot proceed any further.";
567 yError() <<
"ACTION REQUIRED: BOARD" << getProperties().boardnameString <<
"with IP" << getProperties().ipv4addrString <<
"needs a FW update.";
570 if(pc104versionMN->minor != epd->version.minor)
572 yError() <<
"EthResource::verifyEPprotocol() for ep =" << eoprot_EP2string(epd->endpoint) <<
"detected: pc104.version.minor =" << pc104versionMN->minor <<
"and board.version.minor =" << epd->version.minor;
573 yError() <<
"EthResource::verifyEPprotocol() detected mismatching protocol version.minor BOARD" << getProperties().boardnameString <<
"with IP" << getProperties().ipv4addrString <<
"for eoprot_endpoint_management: cannot proceed any further.";
574 yError() <<
"ACTION REQUIRED: BOARD" << getProperties().boardnameString <<
"with IP" << getProperties().ipv4addrString <<
"needs a FW update.";
578 if(epd->endpoint == ep)
580 const eoprot_version_t * pc104versionEP = eoprot_version_of_endpoint_get(ep);
581 if(pc104versionEP->major != epd->version.major)
583 yError() <<
"EthResource::verifyEPprotocol() for ep =" << eoprot_EP2string(epd->endpoint) <<
"detected: pc104.version.major =" << pc104versionEP->major <<
"and board.version.major =" << epd->version.major;
584 yError() <<
"EthResource::verifyEPprotocol() detected mismatching protocol version.major in BOARD" << getProperties().boardnameString <<
"with IP" << getProperties().ipv4addrString <<
" for" << eoprot_EP2string(ep) <<
": cannot proceed any further.";
585 yError() <<
"ACTION REQUIRED: BOARD" << getProperties().boardnameString <<
"with IP" << getProperties().ipv4addrString <<
"needs a FW update to offer services for" << eoprot_EP2string(ep);
588 if(pc104versionEP->minor != epd->version.minor)
590 yError() <<
"EthResource::verifyEPprotocol() for ep =" << eoprot_EP2string(epd->endpoint) <<
"detected: pc104.version.minor =" << pc104versionEP->minor <<
"and board.version.minor =" << epd->version.minor;
591 yError() <<
"EthResource::verifyEPprotocol() detected mismatching protocol version.minor in BOARD" << getProperties().boardnameString <<
"with IP" << getProperties().ipv4addrString <<
" for" << eoprot_EP2string(ep) <<
": annot proceed any further";
592 yError() <<
"ACTION REQUIRED: BOARD" << getProperties().boardnameString <<
"with IP" << getProperties().ipv4addrString <<
"needs a FW update to offer services for" << eoprot_EP2string(ep);
598 verifiedEPprotocol[ep] =
true;
606 bool EthResource::verifyBoard(
void)
608 if((
true == verifyBoardPresence()) &&
609 (
true == verifyBoardTransceiver()) &&
610 (
true == cleanBoardBehaviour()) &&
611 (
true == setTimingOfRunningCycle()) )
620 bool EthResource::verifyBoardPresence(
void)
622 if(verifiedBoardPresence)
627 const double timeout = 1.00;
628 const int retries = 20;
630 double start_time = yarp::os::Time::now();
633 verifiedBoardPresence = nvman.
ping(properties.ipv4addr, boardMNprotocolversion, timeout, retries);
635 double end_time = yarp::os::Time::now();
637 if(
true == verifiedBoardPresence)
639 verifiedBoardPresence =
true;
642 yDebug() <<
"EthResource::verifyBoardPresence() found BOARD" << getProperties().boardnameString <<
"with IP" << getProperties().ipv4addrString <<
"after" << end_time-start_time <<
"seconds";
647 yError() <<
"EthResource::verifyBoardPresence() DID NOT have replies from BOARD" << getProperties().boardnameString <<
"with IP" << getProperties().ipv4addrString <<
"after" << end_time-start_time <<
"seconds: CANNOT PROCEED ANY FURTHER";
650 return(verifiedBoardPresence);
654 bool EthResource::askBoardVersion(
void)
657 if(askedBoardVersion)
662 const double timeout = 0.500;
664 eOprotID32_t id32 = eoprot_ID_get(eoprot_endpoint_management, eoprot_entity_mn_appl, 0, eoprot_tag_mn_appl_status);
665 eOmn_appl_status_t applstatus = {0};
669 askedBoardVersion = nvman.
ask(properties.ipv4addr, id32, &applstatus, timeout);
671 if(
false == askedBoardVersion)
673 yError() <<
"EthResource::askBoardVersion() cannot reach BOARD" << getProperties().boardnameString <<
"with IP" << getProperties().ipv4addrString <<
"w/ timeout of" << timeout <<
"seconds";
680 properties.firmwareversion.major = applstatus.version.major;
681 properties.firmwareversion.minor = applstatus.version.minor;
684 properties.firmwaredate.year = applstatus.buildate.year;
685 properties.firmwaredate.month = applstatus.buildate.month;
686 properties.firmwaredate.day = applstatus.buildate.day;
687 properties.firmwaredate.hour = applstatus.buildate.hour;
688 properties.firmwaredate.min = applstatus.buildate.min;
690 char versstr[32] = {0};
691 snprintf(versstr,
sizeof(versstr),
"ver %d.%d built on ", properties.firmwareversion.major, properties.firmwareversion.minor);
692 char datestr[32] = {0};
693 eo_common_date_to_string(properties.firmwaredate, datestr,
sizeof(datestr));
695 properties.firmwareString = string(versstr) + string(datestr);
698 if(eobool_true == eoboards_is_eth((eObrd_type_t)applstatus.boardtype))
700 detectedBoardType = (eObrd_ethtype_t) applstatus.boardtype;
704 detectedBoardType = eobrd_ethtype_unknown;
707 if(detectedBoardType != properties.boardtype)
709 yWarning() <<
"EthResource::askBoardVersion(): detected wrong board. expecting" << properties.boardtypeString <<
"and detected" << eoboards_type2string2(eoboards_ethtype2type(detectedBoardType), eobool_true);
713 yInfo() <<
"EthResource::askBoardVersion() found BOARD" << properties.boardnameString <<
"@ IP" << properties.ipv4addrString <<
"of type" << properties.boardtypeString<<
"with FW =" << properties.firmwareString;
716 return(askedBoardVersion);
720 bool EthResource::getRemoteValue(
const eOprotID32_t id32,
void *value,
const double timeout,
const unsigned int retries)
722 bool replied =
false;
724 double start_time = yarp::os::Time::now();
728 for(
unsigned int numOfattempts=0; numOfattempts<(retries+1); numOfattempts++)
730 if(
true == nvman.
ask(&transceiver, id32, value, timeout))
739 yWarning() <<
"EthResource::getRemoteValue() cannot have a reply from BOARD" << getProperties().boardnameString <<
"with IP" << getProperties().ipv4addrString <<
"at attempt #" << numOfattempts+1 <<
"w/ timeout of" << timeout <<
"seconds";
744 double end_time = yarp::os::Time::now();
748 yError() <<
" FATAL: EthResource::getRemoteValue() DID NOT have replies from BOARD" << getProperties().boardnameString <<
"with IP" << getProperties().ipv4addrString <<
" even after" << end_time-start_time <<
"seconds: CANNOT PROCEED ANY FURTHER";
755 bool EthResource::getRemoteValues(
const std::vector<eOprotID32_t> &id32s,
const std::vector<void*> &values,
const double timeout)
759 double start_time = yarp::os::Time::now();
761 bool replied = nvman.
ask(&transceiver, id32s, values, timeout);
763 double end_time = yarp::os::Time::now();
767 yError() <<
" FATAL: EthResource::getRemoteValues() DID NOT have replies from BOARD" << getProperties().boardnameString <<
"with IP" << getProperties().ipv4addrString <<
" even after" << end_time-start_time <<
"seconds: CANNOT PROCEED ANY FURTHER";
774 bool EthResource::setRemoteValue(
const eOprotID32_t id32,
void *value)
777 return nvman.
set(properties.ipv4addr, id32, value);
780 bool EthResource::setcheckRemoteValue(
const eOprotID32_t id32,
void *value,
const unsigned int retries,
const double waitbeforecheck,
const double timeout)
783 return nvman.
setcheck(properties.ipv4addr, id32, value, retries, waitbeforecheck, timeout);
786 bool EthResource::CANPrintHandler(eOmn_info_basic_t *infobasic)
789 char canfullmessage[128];
791 static const char * sourcestrings[] =
798 int source = EOMN_INFO_PROPERTIES_FLAGS_get_source(infobasic->properties.flags);
799 const char * str_source = (source > eomn_info_source_can2) ? (sourcestrings[3]) : (sourcestrings[source]);
800 uint16_t address = EOMN_INFO_PROPERTIES_FLAGS_get_address(infobasic->properties.flags);
801 uint8_t *p64 = (uint8_t*)&(infobasic->properties.par64);
803 int msg_id = (p64[1]&0xF0) >> 4;
805 uint32_t sec = infobasic->timestamp / 1000000;
806 uint32_t msec = (infobasic->timestamp % 1000000) / 1000;
807 uint32_t usec = infobasic->timestamp % 1000;
809 const char *boardstr = properties.boardnameString.c_str();
814 snprintf(canfullmessage,
sizeof(canfullmessage),
"Error while parsing the message: CAN address detected is out of allowed range");
815 snprintf(str,
sizeof(str),
"from BOARD %s (%s), src %s, adr %d, time %ds %dm %du: CAN PRINT MESSAGE[id %d] -> %s",
816 properties.ipv4addrString.c_str(),
831 if (c_string_handler[address] == NULL)
835 can_msg.
setCanData(infobasic->properties.par64);
836 can_msg.
setId(msg_id);
837 can_msg.
setSize(infobasic->properties.par16);
838 int ret = c_string_handler[address]->add_string(&can_msg);
843 char* themsg = c_string_handler[address]->get_string(ret);
844 memcpy(canfullmessage, themsg,
sizeof(canfullmessage));
845 canfullmessage[63] = 0;
846 c_string_handler[address]->clear_string(ret);
848 snprintf(str,
sizeof(str),
"from BOARD %s (%s), src %s, adr %d, time %ds %dm %du: CAN PRINT MESSAGE[id %d] -> %s",
849 properties.ipv4addrString.c_str(),
866 bool EthResource::serviceCommand(eOmn_serv_operation_t operation, eOmn_serv_category_t category,
const eOmn_serv_parameter_t* param,
double timeout,
int times)
868 eOprotID32_t id2send = eoprot_ID_get(eoprot_endpoint_management, eoprot_entity_mn_service, 0, eoprot_tag_mn_service_cmmnds_command);
869 eOprotID32_t id2wait = eoprot_ID_get(eoprot_endpoint_management, eoprot_entity_mn_service, 0, eoprot_tag_mn_service_status_commandresult);
871 eOmn_service_cmmnds_command_t command = {0};
872 eOmn_service_command_result_t result = {0};
874 command.operation = operation;
875 command.category = category;
878 memcpy(&command.parameter, param,
sizeof(eOmn_serv_parameter_t));
882 memset(&command.parameter, 0,
sizeof(eOmn_serv_parameter_t));
883 if((eomn_serv_operation_regsig_load == operation) || ((eomn_serv_operation_regsig_clear == operation)))
885 eo_array_New(eOmn_serv_capacity_arrayof_id32, 4, &command.parameter.arrayofid32);
889 command.parameter.configuration.type = eomn_serv_NONE;
896 bool replied =
false;
897 for(
int i=0; i<times; i++)
899 if(
true == nvman.
command(properties.ipv4addr, id2send, &command, id2wait, &result, timeout))
908 yError() <<
"EthResource::serviceCommand() failed an acked activation request to BOARD" << getProperties().boardnameString <<
"with IP" << getProperties().ipv4addrString <<
"after" << times <<
"attempts" <<
"each with waiting timeout of" << timeout <<
"seconds";
914 return(result.latestcommandisok);
918 bool EthResource::serviceVerifyActivate(eOmn_serv_category_t category,
const eOmn_serv_parameter_t* param,
double timeout)
920 return(serviceCommand(eomn_serv_operation_verifyactivate, category, param, timeout, 3));
924 bool EthResource::serviceSetRegulars(eOmn_serv_category_t category, vector<eOprotID32_t> &id32vector,
double timeout)
926 eOmn_serv_parameter_t param = {0};
927 EOarray *array = eo_array_New(eOmn_serv_capacity_arrayof_id32, 4, ¶m.arrayofid32);
928 for(
int i=0; i<id32vector.size(); i++)
930 eOprotID32_t id32 = id32vector.at(i);
931 eo_array_PushBack(array, &id32);
934 regularsAreSet = serviceCommand(eomn_serv_operation_regsig_load, category, ¶m, timeout, 3);
936 return regularsAreSet;
941 bool EthResource::serviceStart(eOmn_serv_category_t category,
double timeout)
943 bool ret = serviceCommand(eomn_serv_operation_start, category, NULL, timeout, 3);
947 isInRunningMode =
true;
954 bool EthResource::serviceStop(eOmn_serv_category_t category,
double timeout)
956 bool ret = serviceCommand(eomn_serv_operation_stop, category, NULL, timeout, 3);
958 if(ret && (category == eomn_serv_category_all))
960 regularsAreSet =
false;
970 bool EthResource::getLocalValue(
const eOprotID32_t id32,
void *
data)
972 return transceiver.read(id32,
data);
976 bool EthResource::setLocalValue(eOprotID32_t id32,
const void *value,
bool overrideROprotection)
978 return transceiver.write(id32, value, overrideROprotection);
982 bool EthResource::isFake()
void setSize(uint8_t size)
void setCanData(uint64_t data)
static TheEthManager * instance()
bool setcheck(const eOprotIP_t ipv4, const eOprotID32_t id32, const void *value, const unsigned int retries=10, double waitbeforecheck=0.001, double timeout=0.5)
bool ask(const eOprotIP_t ipv4, const eOprotID32_t id32, void *value, const double timeout=0.5)
bool command(const eOprotIP_t ipv4, const eOprotID32_t id32cmd, const void *cmd, const eOprotID32_t id32rep, void *rep, double timeout=0.5)
bool ping(const eOprotIP_t ipv4, eoprot_version_t &mnprotversion, const double timeout=0.5, const unsigned int retries=20)
bool set(const eOprotIP_t ipv4, const eOprotID32_t id32, const void *value)
void feat_PrintInfo(char *string)
void feat_PrintError(char *string)
bool read(yarp::os::Searchable &cfgtotal, pc104Data &pc104data)
bool print(const pc104Data &pc104data)
double periodmissingreport
double monitorpresence_periodofmissingreport
bool monitorpresence_enabled
double monitorpresence_timeout
boardProperties properties
eOipv4addressing_t ipv4addressing
std::string ipv4addressingstring
eOmn_appl_config_t txconfig