18 #include <yarp/os/Time.h>
19 #include <yarp/os/Network.h>
20 #include <yarp/os/NetType.h>
23 #include "EOropframe_hid.h"
25 #include "EoProtocol.h"
26 #include "EoManagement.h"
27 #include "EoProtocolMN.h"
28 #include "EoProtocolAS.h"
32 using namespace yarp::os;
33 using namespace yarp::os::impl;
39 FakeEthResource::FakeEthResource()
44 ipv4addressing.addr = 0;
45 ipv4addressing.port = 0;
46 ipv4addrstring =
"0.0.0.0";
47 ethboardtype = eobrd_ethtype_unknown;
48 boardTypeString =
"unknown";
51 isInRunningMode =
false;
53 verifiedBoardPresence =
false;
54 verifiedBoardTransceiver =
false;
56 memset(verifiedEPprotocol, 0,
sizeof(verifiedEPprotocol));
58 usedNumberOfRegularROPs = 0;
59 memset(&boardCommStatus, 0,
sizeof(boardCommStatus));
64 FakeEthResource::~FakeEthResource()
69 bool FakeEthResource::lock(
bool on)
80 bool FakeEthResource::open2(eOipv4addr_t remIP, yarp::os::Searchable &cfgtotal)
93 properties.ipv4addr = remIP;
118 mpConfig.
name = ipv4addrstring +
" (" + boardName +
")";
128 eOipv4addressing_t localIPv4 = ethManager->getLocalIPV4addressing();
131 if(
false == transceiver.init2(
this, cfgtotal, localIPv4, remIP))
133 yError() <<
"EthResource::open2() cannot init transceiver w/ HostTransceiver::init2() for BOARD" << boardName <<
"IP" << ipv4addrstring;
151 bool FakeEthResource::close()
158 const void * FakeEthResource::getUDPtransmit(eOipv4addressing_t &destination,
size_t &sizeofpacket, uint16_t &numofrops)
164 bool FakeEthResource::Tick()
170 bool FakeEthResource::Check()
178 bool FakeEthResource::processRXpacket(
const void *
data,
const size_t size)
191 bool FakeEthResource::isRunning(
void)
193 return(isInRunningMode);
198 bool FakeEthResource::verifyEPprotocol(eOprot_endpoint_t ep)
200 if((uint8_t)ep >= eoprot_endpoints_numberof)
202 yError() <<
"EthResource::verifyEPprotocol() called with wrong ep = " << ep <<
": cannot proceed any further";
206 if(
true == verifiedEPprotocol[ep])
211 if(
false == verifyBoard())
213 yError() <<
"FakeEthResource::verifyEPprotocol() cannot verify BOARD" << getProperties().
boardnameString <<
"with IP" << getProperties().ipv4addrString <<
": cannot proceed any further";
217 verifiedEPprotocol[ep] =
true;
225 bool FakeEthResource::verifyBoard(
void)
230 bool FakeEthResource::getRemoteValue(
const eOprotID32_t id32,
void *value,
const double timeout,
const unsigned int retries)
235 bool FakeEthResource::getRemoteValues(
const std::vector<eOprotID32_t> &id32s,
const std::vector<void*> &values,
const double timeout)
242 bool FakeEthResource::setRemoteValue(
const eOprotID32_t id32,
void *value)
247 bool FakeEthResource::setcheckRemoteValue(
const eOprotID32_t id32,
void *value,
const unsigned int retries,
const double waitbeforecheck,
const double timeout)
254 bool FakeEthResource::CANPrintHandler(eOmn_info_basic_t *infobasic)
256 yError() <<
"FakeEthResource " << boardName <<
": should never be in CANPrintHandler";
261 bool FakeEthResource::serviceVerifyActivate(eOmn_serv_category_t category,
const eOmn_serv_parameter_t* param,
double timeout)
267 bool FakeEthResource::serviceSetRegulars(eOmn_serv_category_t category, vector<eOprotID32_t> &id32vector,
double timeout)
272 bool FakeEthResource::serviceStart(eOmn_serv_category_t category,
double timeout)
274 isInRunningMode =
true;
279 bool FakeEthResource::serviceStop(eOmn_serv_category_t category,
double timeout)
284 bool FakeEthResource::getLocalValue(
const eOprotID32_t id32,
void *
data)
286 bool ret = transceiver.read(id32,
data);
291 if(id32 == eoprot_ID_get(eoprot_endpoint_analogsensors, eoprot_entity_as_strain, 0, eoprot_tag_as_strain_status_fullscale))
294 eOas_arrayofupto12bytes_t * fullscale = (eOas_arrayofupto12bytes_t *)
data;
295 fullscale->head.size = 6;
301 bool FakeEthResource::setLocalValue(eOprotID32_t id32,
const void *value,
bool overrideROprotection)
303 return transceiver.write(id32, value, overrideROprotection);
338 bool FakeEthResource::isFake()
static TheEthManager * instance()
bool read(yarp::os::Searchable &cfgtotal, pc104Data &pc104data)
double periodmissingreport
double monitorpresence_periodofmissingreport
bool monitorpresence_enabled
double monitorpresence_timeout
boardProperties properties
eOipv4addressing_t ipv4addressing
std::string ipv4addressingstring