extern eOresult_t eo_nvset_InitBRD_LoadEPs(EOnvSet* p, eOnvsetOwnership_t ownership, eOipv4addr_t ipaddress, eOnvset_BRDcfg_t* cfgofbrd, eObool_t initNVs) { uint16_t nendpoints = 0; uint16_t i = 0; if((NULL == p) || (NULL == cfgofbrd)) { return(eores_NOK_nullpointer); } if(eores_OK != eo_nvset_InitBRD(p, ownership, ipaddress, cfgofbrd->boardnum)) { return(eores_NOK_generic); } nendpoints = eo_constvector_Size(cfgofbrd->epcfg_constvect); for(i=0; i<nendpoints; i++) { eOprot_EPcfg_t* pepcfg = (eOprot_EPcfg_t*) eo_constvector_At(cfgofbrd->epcfg_constvect, i); if(eobool_true == eoprot_EPcfg_isvalid(pepcfg)) { eo_nvset_LoadEP(p, pepcfg, initNVs); } else { //#warning TBD: put diagnostic message } } return(eores_OK); }
extern const eOnvset_DEVcfg_t* eoprot_robot_DEVcfg_get(uint8_t n) { if(n > eoprot_robot_DEVcfg_numberof()) { return(NULL); } if(0 == s_eoprot_robot_initted) { eoprot_robot_Initialise(); } const eOnvset_DEVcfg_t **p = (const eOnvset_DEVcfg_t**) eo_constvector_At(eoprot_robot_ROBOTcfg.vectorof_devcfgptr, n); return(*p); }
static EOnvsCfg* s_eo_boardtransceiver_nvscfg_get(const eOboardtransceiver_cfg_t *cfg) { EOnvsCfg* nvscfg = s_eo_theboardtrans.nvscfg; eOnvscfg_EP_t *epcfg; const EOconstvector* theepcfgs = NULL; uint16_t nendpoints = 0; uint16_t i; const uint16_t numofdevices = 1; // one device only const uint16_t ondevindex = 0; // hence only index 0 if(NULL != nvscfg) { // if i call it more than once ... then i return the configuration but allocate and init only once return(nvscfg); } theepcfgs = cfg->vectorof_endpoint_cfg; // #warning --> so far the BOARDtransceiver does not use any storage. if needed ... change the NULL into a ... nvscfg = eo_nvscfg_New(numofdevices, NULL, cfg->nvscfgprotection, cfg->mutex_fn_new); //foreach<device> // begin nendpoints = eo_constvector_Size(theepcfgs); // use local-host address as we dont need to put the actual address of board in nvscfg. eo_nvscfg_PushBackDevice(nvscfg, eo_nvscfg_ownership_local, EO_COMMON_IPV4ADDR_LOCALHOST, cfg->hashfunction_ep2index, nendpoints); for(i=0; i<nendpoints; i++) { epcfg = (eOnvscfg_EP_t*) eo_constvector_At(theepcfgs, i); eo_nvscfg_ondevice_PushBackEP(nvscfg, ondevindex, epcfg); } //end eo_nvscfg_data_Initialise(nvscfg); return(nvscfg); }
extern void eom_emsappl_hid_userdef_initialise(EOMtheEMSappl* p) { EOMtheEMSapplCfg* emsapplcfg = eom_emsapplcfg_GetHandle(); // the led-pulser is initted as first thing // pulse led3 forever at 20 hz. eo_ledpulser_Start(eo_ledpulser_GetHandle(), eo_ledpulser_led_three, EOK_reltime1sec/20, 0); { // board number is from IP address s_boardnum = 0; eOipv4addr_t ipaddress = eom_ipnet_GetIPaddress(eom_ipnet_GetHandle()); s_boardnum = ipaddress >> 24; s_boardnum --; if(s_boardnum > 16) { //return; s_boardnum = 0; } //s_boardnum = 0; //it imposes that the board is the eb1 } { // CAN-MAPPING // marco.accame on 19 may 2015: here we load the map of can ... and also we map the entities into some can boards // ... if we have any. EOtheCANmapping * canmap = eo_canmap_Initialise(NULL); // now i load the map of can boards EOconstvector *canboards = eoboardconfig_code2canboards(s_boardnum); eo_canmap_LoadBoards(canmap, canboards); // now i load mc-joints, mc-motors, as-strain, as-mais, sk-skin EOconstvector *entitydes = NULL; // mc entitydes = eoboardconfig_code2entitydescriptors(s_boardnum, eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint); eo_canmap_ConfigEntity(canmap, eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, entitydes); entitydes = eoboardconfig_code2entitydescriptors(s_boardnum, eoprot_endpoint_motioncontrol, eoprot_entity_mc_motor); eo_canmap_ConfigEntity(canmap, eoprot_endpoint_motioncontrol, eoprot_entity_mc_motor, entitydes); // as entitydes = eoboardconfig_code2entitydescriptors(s_boardnum, eoprot_endpoint_analogsensors, eoprot_entity_as_strain); eo_canmap_ConfigEntity(canmap, eoprot_endpoint_analogsensors, eoprot_entity_as_strain, entitydes); entitydes = eoboardconfig_code2entitydescriptors(s_boardnum, eoprot_endpoint_analogsensors, eoprot_entity_as_mais); eo_canmap_ConfigEntity(canmap, eoprot_endpoint_analogsensors, eoprot_entity_as_mais, entitydes); // sk entitydes = eoboardconfig_code2entitydescriptors(s_boardnum, eoprot_endpoint_skin, eoprot_entity_sk_skin); eo_canmap_ConfigEntity(canmap, eoprot_endpoint_skin, eoprot_entity_sk_skin, entitydes); } { // CAN-PROTOCOL EOtheCANprotocol * canprot = eo_canprot_Initialise(NULL); } { // ETH-PROTOCOL // marco.accame on 24 apr 2015: here is how to customise the eth protocol from a generic to a specific board // so far, we can keep it in here. but further on we shall customise one endpoint at a time in runtime. EOnvSet* nvset = eom_emstransceiver_GetNVset(eom_emstransceiver_GetHandle()); uint8_t i = 0; // 1. set the board number. the value of the generic board is 99. // the correct value is used only for retrieving it later on and perform specific actions based on the board number eo_nvset_BRDlocalsetnumber(nvset, s_boardnum); EOconstvector* epcfg_cvector = eoboardconfig_code2EPcfg(s_boardnum); // 2. load all the endpoints specific to this board. the generic board loads only management uint16_t numofepcfgs = eo_constvector_Size(epcfg_cvector); for(i=0; i<numofepcfgs; i++) { eOprot_EPcfg_t* epcfg = (eOprot_EPcfg_t*) eo_constvector_At(epcfg_cvector, i); if(eobool_true == eoprot_EPcfg_isvalid(epcfg)) { eo_nvset_LoadEP(nvset, epcfg, eobool_true); } } // now we must define the .... proxy rules // if we have board number equal to 1 or 3 ... (eb2 or eb4) then we set it for mc only eOprotBRD_t localboard = eoprot_board_local_get(); if((1 == localboard) || (3 == localboard)) { eoprot_config_proxied_variables(eoprot_board_localboard, eoprot_endpoint_motioncontrol, eoprot_b02_b04_mc_isproxied); } } // start the application body eOemsapplbody_cfg_t applbodyconfig; memcpy(&applbodyconfig, &theemsapplbodycfg, sizeof(eOemsapplbody_cfg_t)); // now i get the encoder config const eOappEncReader_cfg_t *enccfg = eoboardconfig_code2encoderconfig(s_boardnum); memcpy(&applbodyconfig.encoderreaderconfig, enccfg, sizeof(eOappEncReader_cfg_t)); eo_emsapplBody_Initialise(&applbodyconfig); }