extern eOresult_t eoprot_b06_Initialise(void* p, eObool_t islocal) { // must initialise the mc, the mn, the ... eoprot_config_endpoint_entities(eoprot_b06_boardnumber, eoprot_endpoint_management, eoprot_b06_mn_entities_numberofeach); eoprot_config_endpoint_entities(eoprot_b06_boardnumber, eoprot_endpoint_motioncontrol, eoprot_b06_mc_entities_numberofeach); eoprot_config_endpoint_entities(eoprot_b06_boardnumber, eoprot_endpoint_analogsensors, eoprot_b06_as_entities_numberofeach); if(eobool_true == islocal) { eoprot_config_board_local(eoprot_b06_boardnumber); eoprot_config_proxied_variables(eoprot_b06_boardnumber, eoprot_b06_isvariableproxied); } return(eores_OK); }
extern eOresult_t eo_nvset_BRDlocalsetnumber(EOnvSet* p, eOnvBRD_t brdnum) { if(NULL == p) { return(eores_NOK_generic); } if(0 == p->theboard.ipaddress) { // not already initted return(eores_NOK_generic); } if(eo_nvset_ownership_local == p->theboard.ownership) { // by this call we can later on retrieve a number for the local board. eoprot_config_board_local(brdnum); return(eores_OK); } return(eores_NOK_generic); }
extern eOresult_t eo_nvset_InitBRD(EOnvSet* p, eOnvsetOwnership_t ownership, eOipv4addr_t ipaddress, eOnvBRD_t brdnum) { // eOresult_t res = eores_NOK_generic; if(NULL == p) { return(eores_NOK_generic); } if(0 != p->theboard.ipaddress) { // already initted return(eores_NOK_generic); } if(0 == ipaddress) { // the ipaddress must be non-zero return(eores_NOK_generic); } if(eo_nvset_ownership_local == ownership) { // by this call we can later on retrieve a number for the local board. eoprot_config_board_local(brdnum); } else { // by this call the eoprot library reserves space for a given board number if(eores_OK != eoprot_config_board_reserve(brdnum)) { //#warning TBD: shall i call the error manager? return(eores_NOK_generic); } } if(eores_OK != s_eo_nvset_InitBRD(p, ownership, ipaddress, brdnum)) { return(eores_NOK_generic); } return(eores_OK); }
static void s_eoprot_ep_mn_fun_configcommand(eOmn_command_t* command) { uint8_t size, i; eOropSIGcfg_t *sigcfg; eOropdescriptor_t ropdesc; EOtransceiver* theems00transceiver; //eOmn_cmd_config_t* cmdconfig = (eOmn_cmd_config_t*)&command->cmd; /////// not correct. eOmn_cmd_config_t* cmdconfig = &command->cmd.config; EOarray *array = (EOarray*)cmdconfig->array; uint16_t targetcapacity = (sizeof(cmdconfig->array) - sizeof(eOarray_head_t)) / sizeof(eOropSIGcfg_t); eOmn_opc_t opc = (eOmn_opc_t) cmdconfig->opcpar.opc; eOresult_t res; if(NULL == (theems00transceiver = eo_boardtransceiver_GetTransceiver(eo_boardtransceiver_GetHandle()))) { return; } switch(opc) { case eomn_opc_config_REGROPs_clear: { // just clear eo_transceiver_RegularROPs_Clear(theems00transceiver); } break; case eomn_opc_config_REGROPs_assign: { // clear and load all the sigcfg in the array if((eo_array_ItemSize(array) != sizeof(eOropSIGcfg_t)) || (targetcapacity != eo_array_Capacity(array)) || ((size = eo_array_Size(array)) > targetcapacity)) { return; } eo_transceiver_RegularROPs_Clear(theems00transceiver); for(i=0; i<size; i++) { sigcfg = (eOropSIGcfg_t*)eo_array_At(array, i); memcpy(&ropdesc.control, &eok_ropctrl_basic, sizeof(eOropctrl_t)); ropdesc.control.plustime = (eobool_true == cmdconfig->opcpar.plustime) ? (1) : (0); ropdesc.control.plussign = (eobool_true == cmdconfig->opcpar.plussign) ? (1) : (0); ropdesc.ropcode = eo_ropcode_sig; ropdesc.id32 = sigcfg->id32; ropdesc.signature = cmdconfig->opcpar.signature; res = eo_transceiver_RegularROP_Load(theems00transceiver, &ropdesc); res = res; if(eores_OK != res) { eo_theEMSdgn_UpdateApplCore(eo_theEMSdgn_GetHandle()); eo_theEMSdgn_Signalerror(eo_theEMSdgn_GetHandle(), eodgn_nvidbdoor_emsapplcommon , 1000); } } } break; case eomn_opc_config_REGROPs_append: { // dont clear and load all the sigcfg in the array if((eo_array_ItemSize(array) != sizeof(eOropSIGcfg_t)) || (targetcapacity != eo_array_Capacity(array)) || ((size = eo_array_Size(array)) > targetcapacity)) { return; } for(i=0; i<size; i++) { sigcfg = (eOropSIGcfg_t*)eo_array_At(array, i); memcpy(&ropdesc.control, &eok_ropctrl_basic, sizeof(eOropctrl_t)); ropdesc.control.plustime = (eobool_true == cmdconfig->opcpar.plustime) ? (1) : (0); ropdesc.control.plussign = (eobool_true == cmdconfig->opcpar.plussign) ? (1) : (0); ropdesc.ropcode = eo_ropcode_sig; ropdesc.id32 = sigcfg->id32; ropdesc.signature = cmdconfig->opcpar.signature; res = eo_transceiver_RegularROP_Load(theems00transceiver, &ropdesc); res = res; if(eores_OK != res) { eo_theEMSdgn_UpdateApplCore(eo_theEMSdgn_GetHandle()); eo_theEMSdgn_Signalerror(eo_theEMSdgn_GetHandle(), eodgn_nvidbdoor_emsapplcommon , 1000); } } } break; case eomn_opc_config_REGROPs_remove: { // remove all the sigcfg in the array if((eo_array_ItemSize(array) != sizeof(eOropSIGcfg_t)) || (targetcapacity != eo_array_Capacity(array)) || ((size = eo_array_Size(array)) > targetcapacity)) { return; } for(i=0; i<size; i++) { sigcfg = (eOropSIGcfg_t*)eo_array_At(array, i); memcpy(&ropdesc.control, &eok_ropctrl_basic, sizeof(eOropctrl_t)); ropdesc.control.plustime = (eobool_true == cmdconfig->opcpar.plustime) ? (1) : (0); ropdesc.control.plussign = (eobool_true == cmdconfig->opcpar.plussign) ? (1) : (0); ropdesc.ropcode = eo_ropcode_sig; ropdesc.id32 = sigcfg->id32; ropdesc.signature = cmdconfig->opcpar.signature; res = eo_transceiver_RegularROP_Unload(theems00transceiver, &ropdesc); res = res; } } break; case eomn_opc_config_PROT_boardnumber: { // simply set the byte in array[0] as the new localboard number //eOprotBRD_t brdnum = command->cmd.config.array[0]; eoprot_config_board_local(command->cmd.config.array[0]); } break; case eomn_opc_config_PROT_endpoint: { // simply use the bytes in array[0->7] as a eOprot_EPcfg_t. but only if the EP is valid and not loaded yet. eOprot_EPcfg_t *epcfg = (eOprot_EPcfg_t*) &command->cmd.config.array[0]; if(eobool_true == eoprot_EPcfg_isvalid(epcfg)) { if(eobool_false == eoprot_endpoint_configured_is(eoprot_board_localboard, epcfg->endpoint)) { EOnvSet* nvset = eom_emstransceiver_GetNVset(eom_emstransceiver_GetHandle()); eo_nvset_LoadEP(nvset, epcfg, eobool_true); } } } break; default: { } break; } }