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;
59 memset(verifiedEPprotocol, 0,
sizeof(verifiedEPprotocol));
61 usedNumberOfRegularROPs = 0;
63 for(
int i = 0; i<16; i++)
65 c_string_handler[i] = NULL;
68 std::string
tmp = yarp::conf::environment::get_string(
"ETH_VERBOSEWHENOK");
71 verbosewhenok = (bool)(yarp::conf::numeric::from_string(
tmp, 0U));
75 verbosewhenok =
false;
80 regularsAreSet =
false;
84 EthResource::~EthResource()
89 for(
int i=0; i<16; i++)
91 if (c_string_handler[i] != NULL)
93 delete c_string_handler[i];
94 c_string_handler[i] = NULL;
99 bool EthResource::lock(
bool on)
110 bool EthResource::open2(eOipv4addr_t remIP, yarp::os::Searchable &cfgtotal)
125 properties.ipv4addr = remIP;
150 eOipv4addressing_t localIPv4 = ethManager->getLocalIPV4addressing();
153 if(
false == transceiver.init2(
this, cfgtotal, localIPv4, remIP))
155 yError() <<
"EthResource::open2() cannot init transceiver w/ HostTransceiver::init2() for BOARD" << properties.boardnameString <<
"IP" << properties.ipv4addrString;
162 monitorpresence.config(mpConfig);
163 monitorpresence.tick();
173 bool EthResource::close()
180 const void * EthResource::getUDPtransmit(eOipv4addressing_t &destination,
size_t &sizeofpacket, uint16_t &numofrops)
182 destination = properties.ipv4addressing;
183 const void * udp = transceiver.getUDP(sizeofpacket, numofrops);
200 bool EthResource::Tick()
202 monitorpresence.tick();
207 bool EthResource::Check()
209 if(
false == regularsAreSet)
214 return monitorpresence.check();
219 bool EthResource::processRXpacket(
const void *
data,
const size_t size)
221 return transceiver.parseUDP(
data, size);
239 bool EthResource::isRunning(
void)
241 return(isInRunningMode);
246 bool EthResource::verifyBoardTransceiver()
250 if(verifiedBoardTransceiver)
256 #define DONT_ASK_COMM_STATUS
258 #if defined(DONT_ASK_COMM_STATUS)
260 const eoprot_version_t * pc104versionMN = eoprot_version_of_endpoint_get(eoprot_endpoint_management);
261 const eoprot_version_t * brdversionMN = &boardMNprotocolversion;
270 const eoprot_version_t * pc104versionMN = eoprot_version_of_endpoint_get(eoprot_endpoint_management);
271 const double timeout = 0.100;
273 eOprotID32_t id32 = eoprot_ID_get(eoprot_endpoint_management, eoprot_entity_mn_comm, 0, eoprot_tag_mn_comm_status);
274 eOmn_comm_status_t brdstatus = {0};
277 bool rr = nvman.
ask(ipv4addr, id32, &brdstatus, timeout);
281 yError() <<
"EthResource::verifyBoardTransceiver() cannot read brdstatus w/ theNVmanager for BOARD" << getProperties().boardnameString <<
"with IP" << getProperties().ipv4addrString <<
": cannot proceed any further";
285 eoprot_version_t * brdversionMN = (eoprot_version_t*)&brdstatus.managementprotocolversion;
289 if(pc104versionMN->major != brdversionMN->major)
291 yError() <<
"EthResource::verifyBoardTransceiver() detected different mn protocol major versions: local =" << pc104versionMN->major <<
", remote =" << brdversionMN->major <<
": cannot proceed any further";
292 yError() <<
"ACTION REQUIRED: BOARD" << getProperties().boardnameString <<
"with IP" << getProperties().ipv4addrString <<
"needs a FW update.";
296 if(pc104versionMN->minor != brdversionMN->minor)
298 yError() <<
"EthResource::verifyBoardTransceiver() detected different mn protocol minor versions: local =" << pc104versionMN->minor <<
", remote =" << brdversionMN->minor <<
": cannot proceed any further.";
299 yError() <<
"ACTION REQUIRED: BOARD" << getProperties().boardnameString <<
"with IP" << getProperties().ipv4addrString <<
"needs a FW update.";
306 yDebug() <<
"EthResource::verifyBoardTransceiver() has validated the transceiver of BOARD" << getProperties().boardnameString <<
"with IP" << getProperties().ipv4addrString;
309 verifiedBoardTransceiver =
true;
316 bool EthResource::setTimingOfRunningCycle()
329 eOprotID32_t id32 = eoprot_ID_get(eoprot_endpoint_management, eoprot_entity_mn_appl, 0, eoprot_tag_mn_appl_config);
333 if(
false == nvman.
setcheck(properties.ipv4addr, id32, &txconfig, 5, 0.010, 2.0))
335 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";
342 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";
353 bool EthResource::cleanBoardBehaviour(
void)
355 if(cleanedBoardBehaviour)
361 if(
false == serviceStop(eomn_serv_category_all))
363 yError() <<
"EthResource::cleanBoardBehaviour() cannot stop services for BOARD" << getProperties().boardnameString <<
"with IP" << getProperties().ipv4addrString <<
": cannot proceed any further";
367 regularsAreSet =
false;
372 yDebug() <<
"EthResource::cleanBoardBehaviour() has cleaned the application in BOARD" << getProperties().boardnameString <<
"with IP" << getProperties().ipv4addrString <<
": config mode + cleared all its regulars";
375 cleanedBoardBehaviour =
true;
381 bool EthResource::testMultipleASK()
389 eOprotID32_t id32_commstatus = eoprot_ID_get(eoprot_endpoint_management, eoprot_entity_mn_comm, 0, eoprot_tag_mn_comm_status);
390 eOmn_comm_status_t value_commstatus = {0};
392 eOprotID32_t id32_applconfig = eoprot_ID_get(eoprot_endpoint_management, eoprot_entity_mn_appl, 0, eoprot_tag_mn_appl_config);
393 eOmn_appl_config_t value_applconfig = {0};
395 eOprotID32_t id32_applconfig_txratedivider = eoprot_ID_get(eoprot_endpoint_management, eoprot_entity_mn_appl, 0, eoprot_tag_mn_appl_config_txratedivider);
396 uint8_t txratedivider = 0;
398 std::vector<eOprotID32_t> id32s;
399 std::vector<void*> values;
401 id32s.push_back(id32_commstatus);
402 values.push_back(&value_commstatus);
404 id32s.push_back(id32_applconfig);
405 values.push_back(&value_applconfig);
407 id32s.push_back(id32_applconfig_txratedivider);
408 values.push_back(&txratedivider);
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);
433 double tprev = SystemClock::nowSystem();
434 double tcurr = SystemClock::nowSystem();
436 double delta = tcurr - tprev;
438 yDebug() <<
"before";
439 yDebug() <<
"value_commstatus.managementprotocolversion.major = " << value_commstatus.managementprotocolversion.major <<
"value_commstatus.managementprotocolversion.minor = " << value_commstatus.managementprotocolversion.minor;
440 yDebug() <<
"value_applconfig.cycletime = " << value_applconfig.cycletime <<
"value_applconfig.txratedivider" << value_applconfig.txratedivider <<
"etc";
441 yDebug() <<
"txratedivider = " << txratedivider;
443 tprev = SystemClock::nowSystem();
445 bool ok = getRemoteValues(id32s, values, 3.0);
446 delta = SystemClock::nowSystem() - tprev;
448 yDebug() <<
"parallel mode: after" << delta <<
"seconds";
449 yDebug() <<
"value_commstatus.managementprotocolversion.major = " << value_commstatus.managementprotocolversion.major <<
"value_commstatus.managementprotocolversion.minor = " << value_commstatus.managementprotocolversion.minor;
450 yDebug() <<
"value_applconfig.cycletime = " << value_applconfig.cycletime <<
"value_applconfig.txratedivider" << value_applconfig.txratedivider <<
"etc";
451 yDebug() <<
"txratedivider = " << txratedivider;
453 memset(&value_commstatus, 0,
sizeof(value_commstatus));
454 memset(&value_applconfig, 0,
sizeof(value_applconfig));
458 tprev = SystemClock::nowSystem();
459 nvman.
ask(&transceiver, id32_commstatus, &value_commstatus, 3.0);
460 nvman.
ask(&transceiver, id32_applconfig, &value_applconfig, 3.0);
461 nvman.
ask(&transceiver, id32_applconfig_txratedivider, &txratedivider, 3.0);
462 nvman.
ask(&transceiver, id32_applconfig_txratedivider, &txratedivider, 3.0);
463 nvman.
ask(&transceiver, id32_applconfig_txratedivider, &txratedivider, 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 delta = SystemClock::nowSystem() - tprev;
471 yDebug() <<
"serial mode: after" << delta <<
"seconds";
472 yDebug() <<
"value_commstatus.managementprotocolversion.major = " << value_commstatus.managementprotocolversion.major <<
"value_commstatus.managementprotocolversion.minor = " << value_commstatus.managementprotocolversion.minor;
473 yDebug() <<
"value_applconfig.cycletime = " << value_applconfig.cycletime <<
"value_applconfig.txratedivider" << value_applconfig.txratedivider <<
"etc";
474 yDebug() <<
"txratedivider = " << txratedivider;
484 bool EthResource::verifyEPprotocol(eOprot_endpoint_t ep)
486 if((uint8_t)ep >= eoprot_endpoints_numberof)
488 yError() <<
"EthResource::verifyEPprotocol() called with wrong ep = " << ep <<
": cannot proceed any further";
492 if(
true == verifiedEPprotocol[ep])
497 if(
false == verifyBoard())
499 yError() <<
"EthResource::verifyEPprotocol() cannot verify BOARD" << getProperties().boardnameString <<
"with IP" << getProperties().ipv4addrString <<
": cannot proceed any further";
503 if(
false == askBoardVersion())
505 yError() <<
"EthResource::verifyEPprotocol() cannot ask the version to BOARD" << getProperties().boardnameString <<
"with IP" << getProperties().ipv4addrString <<
": cannot proceed any further";
518 const double timeout = 0.100;
520 eOprotID32_t id2send = eo_prot_ID32dummy;
521 eOprotID32_t id2wait = eo_prot_ID32dummy;
522 eOmn_command_t command = {0};
526 id2send = eoprot_ID_get(eoprot_endpoint_management, eoprot_entity_mn_comm, 0, eoprot_tag_mn_comm_cmmnds_command_queryarray);
527 memset(&command, 0,
sizeof(command));
528 command.cmd.opc = eomn_opc_query_array_EPdes;
529 command.cmd.queryarray.opcpar.opc = eomn_opc_query_array_EPdes;
530 command.cmd.queryarray.opcpar.endpoint = eoprot_endpoint_all;
531 command.cmd.queryarray.opcpar.setnumber = 0;
532 command.cmd.queryarray.opcpar.setsize = 0;
535 id2wait = eoprot_ID_get(eoprot_endpoint_management, eoprot_entity_mn_comm, 0, eoprot_tag_mn_comm_cmmnds_command_replyarray);
539 if(
false == nvman.
command(properties.ipv4addr, id2send, &command, id2wait, &command, timeout))
541 yError() <<
"EthResource::verifyEPprotocol() retrieve the endpoint descriptors from BOARD" << getProperties().boardnameString <<
"with IP" << getProperties().ipv4addrString <<
": cannot proceed any further";
546 eOmn_cmd_replyarray_t* cmdreplyarray = (eOmn_cmd_replyarray_t*)&command.cmd.replyarray;
547 EOarray* array = (EOarray*)cmdreplyarray->array;
550 uint8_t sizeofarray = eo_array_Size(array);
553 for(
int i=0; i<sizeofarray; i++)
555 eoprot_endpoint_descriptor_t *epd = (eoprot_endpoint_descriptor_t*)eo_array_At(array, i);
557 if(epd->endpoint == eoprot_endpoint_management)
559 const eoprot_version_t * pc104versionMN = eoprot_version_of_endpoint_get(eoprot_endpoint_management);
560 if(pc104versionMN->major != epd->version.major)
562 yError() <<
"EthResource::verifyEPprotocol() for ep =" << eoprot_EP2string(epd->endpoint) <<
"detected: pc104.version.major =" << pc104versionMN->major <<
"and board.version.major =" << epd->version.major;
563 yError() <<
"EthResource::verifyEPprotocol() detected mismatching protocol version.major in BOARD" << getProperties().boardnameString <<
"with IP" << getProperties().ipv4addrString <<
"for eoprot_endpoint_management: cannot proceed any further.";
564 yError() <<
"ACTION REQUIRED: BOARD" << getProperties().boardnameString <<
"with IP" << getProperties().ipv4addrString <<
"needs a FW update.";
567 if(pc104versionMN->minor != epd->version.minor)
569 yError() <<
"EthResource::verifyEPprotocol() for ep =" << eoprot_EP2string(epd->endpoint) <<
"detected: pc104.version.minor =" << pc104versionMN->minor <<
"and board.version.minor =" << epd->version.minor;
570 yError() <<
"EthResource::verifyEPprotocol() detected mismatching protocol version.minor BOARD" << getProperties().boardnameString <<
"with IP" << getProperties().ipv4addrString <<
"for eoprot_endpoint_management: cannot proceed any further.";
571 yError() <<
"ACTION REQUIRED: BOARD" << getProperties().boardnameString <<
"with IP" << getProperties().ipv4addrString <<
"needs a FW update.";
575 if(epd->endpoint == ep)
577 const eoprot_version_t * pc104versionEP = eoprot_version_of_endpoint_get(ep);
578 if(pc104versionEP->major != epd->version.major)
580 yError() <<
"EthResource::verifyEPprotocol() for ep =" << eoprot_EP2string(epd->endpoint) <<
"detected: pc104.version.major =" << pc104versionEP->major <<
"and board.version.major =" << epd->version.major;
581 yError() <<
"EthResource::verifyEPprotocol() detected mismatching protocol version.major in BOARD" << getProperties().boardnameString <<
"with IP" << getProperties().ipv4addrString <<
" for" << eoprot_EP2string(ep) <<
": cannot proceed any further.";
582 yError() <<
"ACTION REQUIRED: BOARD" << getProperties().boardnameString <<
"with IP" << getProperties().ipv4addrString <<
"needs a FW update to offer services for" << eoprot_EP2string(ep);
585 if(pc104versionEP->minor != epd->version.minor)
587 yError() <<
"EthResource::verifyEPprotocol() for ep =" << eoprot_EP2string(epd->endpoint) <<
"detected: pc104.version.minor =" << pc104versionEP->minor <<
"and board.version.minor =" << epd->version.minor;
588 yError() <<
"EthResource::verifyEPprotocol() detected mismatching protocol version.minor in BOARD" << getProperties().boardnameString <<
"with IP" << getProperties().ipv4addrString <<
" for" << eoprot_EP2string(ep) <<
": annot proceed any further";
589 yError() <<
"ACTION REQUIRED: BOARD" << getProperties().boardnameString <<
"with IP" << getProperties().ipv4addrString <<
"needs a FW update to offer services for" << eoprot_EP2string(ep);
595 verifiedEPprotocol[ep] =
true;
603 bool EthResource::verifyBoard(
void)
605 if((
true == verifyBoardPresence()) &&
606 (
true == verifyBoardTransceiver()) &&
607 (
true == cleanBoardBehaviour()) &&
608 (
true == setTimingOfRunningCycle()) )
617 bool EthResource::verifyBoardPresence(
void)
619 if(verifiedBoardPresence)
624 const double timeout = 1.00;
625 const int retries = 20;
627 double start_time = yarp::os::Time::now();
630 verifiedBoardPresence = nvman.
ping(properties.ipv4addr, boardMNprotocolversion, timeout, retries);
632 double end_time = yarp::os::Time::now();
634 if(
true == verifiedBoardPresence)
636 verifiedBoardPresence =
true;
639 yDebug() <<
"EthResource::verifyBoardPresence() found BOARD" << getProperties().boardnameString <<
"with IP" << getProperties().ipv4addrString <<
"after" << end_time-start_time <<
"seconds";
644 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";
647 return(verifiedBoardPresence);
651 bool EthResource::askBoardVersion(
void)
654 if(askedBoardVersion)
659 const double timeout = 0.500;
661 eOprotID32_t id32 = eoprot_ID_get(eoprot_endpoint_management, eoprot_entity_mn_appl, 0, eoprot_tag_mn_appl_status);
662 eOmn_appl_status_t applstatus = {0};
666 askedBoardVersion = nvman.
ask(properties.ipv4addr, id32, &applstatus, timeout);
668 if(
false == askedBoardVersion)
670 yError() <<
"EthResource::askBoardVersion() cannot reach BOARD" << getProperties().boardnameString <<
"with IP" << getProperties().ipv4addrString <<
"w/ timeout of" << timeout <<
"seconds";
677 properties.firmwareversion.major = applstatus.version.major;
678 properties.firmwareversion.minor = applstatus.version.minor;
681 properties.firmwaredate.year = applstatus.buildate.year;
682 properties.firmwaredate.month = applstatus.buildate.month;
683 properties.firmwaredate.day = applstatus.buildate.day;
684 properties.firmwaredate.hour = applstatus.buildate.hour;
685 properties.firmwaredate.min = applstatus.buildate.min;
687 char versstr[32] = {0};
688 snprintf(versstr,
sizeof(versstr),
"ver %d.%d built on ", properties.firmwareversion.major, properties.firmwareversion.minor);
689 char datestr[32] = {0};
690 eo_common_date_to_string(properties.firmwaredate, datestr,
sizeof(datestr));
692 properties.firmwareString = string(versstr) + string(datestr);
695 if(eobool_true == eoboards_is_eth((eObrd_type_t)applstatus.boardtype))
697 detectedBoardType = (eObrd_ethtype_t) applstatus.boardtype;
701 detectedBoardType = eobrd_ethtype_unknown;
704 if(detectedBoardType != properties.boardtype)
706 yWarning() <<
"EthResource::askBoardVersion(): detected wrong board. expecting" << properties.boardtypeString <<
"and detected" << eoboards_type2string2(eoboards_ethtype2type(detectedBoardType), eobool_true);
710 yInfo() <<
"EthResource::askBoardVersion() found BOARD" << properties.boardnameString <<
"@ IP" << properties.ipv4addrString <<
"of type" << properties.boardtypeString<<
"with FW =" << properties.firmwareString;
713 return(askedBoardVersion);
717 bool EthResource::getRemoteValue(
const eOprotID32_t id32,
void *value,
const double timeout,
const unsigned int retries)
719 bool replied =
false;
721 double start_time = yarp::os::Time::now();
725 for(
unsigned int numOfattempts=0; numOfattempts<(retries+1); numOfattempts++)
727 if(
true == nvman.
ask(&transceiver, id32, value, timeout))
736 yWarning() <<
"EthResource::getRemoteValue() cannot have a reply from BOARD" << getProperties().boardnameString <<
"with IP" << getProperties().ipv4addrString <<
"at attempt #" << numOfattempts+1 <<
"w/ timeout of" << timeout <<
"seconds";
741 double end_time = yarp::os::Time::now();
745 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";
752 bool EthResource::getRemoteValues(
const std::vector<eOprotID32_t> &id32s,
const std::vector<void*> &values,
const double timeout)
756 double start_time = yarp::os::Time::now();
758 bool replied = nvman.
ask(&transceiver, id32s, values, timeout);
760 double end_time = yarp::os::Time::now();
764 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";
771 bool EthResource::setRemoteValue(
const eOprotID32_t id32,
void *value)
774 return nvman.
set(properties.ipv4addr, id32, value);
777 bool EthResource::setcheckRemoteValue(
const eOprotID32_t id32,
void *value,
const unsigned int retries,
const double waitbeforecheck,
const double timeout)
780 return nvman.
setcheck(properties.ipv4addr, id32, value, retries, waitbeforecheck, timeout);
783 bool EthResource::CANPrintHandler(eOmn_info_basic_t *infobasic)
786 char canfullmessage[128];
788 static const char * sourcestrings[] =
795 int source = EOMN_INFO_PROPERTIES_FLAGS_get_source(infobasic->properties.flags);
796 const char * str_source = (source > eomn_info_source_can2) ? (sourcestrings[3]) : (sourcestrings[source]);
797 uint16_t address = EOMN_INFO_PROPERTIES_FLAGS_get_address(infobasic->properties.flags);
798 uint8_t *p64 = (uint8_t*)&(infobasic->properties.par64);
800 int msg_id = (p64[1]&0xF0) >> 4;
802 uint32_t sec = infobasic->timestamp / 1000000;
803 uint32_t msec = (infobasic->timestamp % 1000000) / 1000;
804 uint32_t usec = infobasic->timestamp % 1000;
806 const char *boardstr = properties.boardnameString.c_str();
811 snprintf(canfullmessage,
sizeof(canfullmessage),
"Error while parsing the message: CAN address detected is out of allowed range");
812 snprintf(str,
sizeof(str),
"from BOARD %s (%s), src %s, adr %d, time %ds %dm %du: CAN PRINT MESSAGE[id %d] -> %s",
813 properties.ipv4addrString.c_str(),
828 if (c_string_handler[address] == NULL)
832 can_msg.
setCanData(infobasic->properties.par64);
833 can_msg.
setId(msg_id);
834 can_msg.
setSize(infobasic->properties.par16);
835 int ret = c_string_handler[address]->add_string(&can_msg);
840 char* themsg = c_string_handler[address]->get_string(ret);
841 memcpy(canfullmessage, themsg,
sizeof(canfullmessage));
842 canfullmessage[63] = 0;
843 c_string_handler[address]->clear_string(ret);
845 snprintf(str,
sizeof(str),
"from BOARD %s (%s), src %s, adr %d, time %ds %dm %du: CAN PRINT MESSAGE[id %d] -> %s",
846 properties.ipv4addrString.c_str(),
863 bool EthResource::serviceCommand(eOmn_serv_operation_t operation, eOmn_serv_category_t category,
const eOmn_serv_parameter_t* param,
double timeout,
int times)
865 eOprotID32_t id2send = eoprot_ID_get(eoprot_endpoint_management, eoprot_entity_mn_service, 0, eoprot_tag_mn_service_cmmnds_command);
866 eOprotID32_t id2wait = eoprot_ID_get(eoprot_endpoint_management, eoprot_entity_mn_service, 0, eoprot_tag_mn_service_status_commandresult);
868 eOmn_service_cmmnds_command_t command = {0};
869 eOmn_service_command_result_t result = {0};
871 command.operation = operation;
872 command.category = category;
875 memcpy(&command.parameter, param,
sizeof(eOmn_serv_parameter_t));
879 memset(&command.parameter, 0,
sizeof(eOmn_serv_parameter_t));
880 if((eomn_serv_operation_regsig_load == operation) || ((eomn_serv_operation_regsig_clear == operation)))
882 eo_array_New(eOmn_serv_capacity_arrayof_id32, 4, &command.parameter.arrayofid32);
886 command.parameter.configuration.type = eomn_serv_NONE;
893 bool replied =
false;
894 for(
int i=0; i<times; i++)
896 if(
true == nvman.
command(properties.ipv4addr, id2send, &command, id2wait, &result, timeout))
905 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";
911 return(result.latestcommandisok);
915 bool EthResource::serviceVerifyActivate(eOmn_serv_category_t category,
const eOmn_serv_parameter_t* param,
double timeout)
917 return(serviceCommand(eomn_serv_operation_verifyactivate, category, param, timeout, 3));
921 bool EthResource::serviceSetRegulars(eOmn_serv_category_t category, vector<eOprotID32_t> &id32vector,
double timeout)
923 eOmn_serv_parameter_t param = {0};
924 EOarray *array = eo_array_New(eOmn_serv_capacity_arrayof_id32, 4, ¶m.arrayofid32);
925 for(
int i=0; i<id32vector.size(); i++)
927 eOprotID32_t id32 = id32vector.at(i);
928 eo_array_PushBack(array, &id32);
931 regularsAreSet = serviceCommand(eomn_serv_operation_regsig_load, category, ¶m, timeout, 3);
933 return regularsAreSet;
938 bool EthResource::serviceStart(eOmn_serv_category_t category,
double timeout)
940 bool ret = serviceCommand(eomn_serv_operation_start, category, NULL, timeout, 3);
944 isInRunningMode =
true;
951 bool EthResource::serviceStop(eOmn_serv_category_t category,
double timeout)
953 bool ret = serviceCommand(eomn_serv_operation_stop, category, NULL, timeout, 3);
955 if(ret && (category == eomn_serv_category_all))
957 regularsAreSet =
false;
967 bool EthResource::getLocalValue(
const eOprotID32_t id32,
void *
data)
969 return transceiver.read(id32,
data);
973 bool EthResource::setLocalValue(eOprotID32_t id32,
const void *value,
bool overrideROprotection)
975 return transceiver.write(id32, value, overrideROprotection);
979 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