static void s_eoprot_ep_mn_fun_apply_config_txratedivider(uint8_t txratedivider) { eOprotID32_t id32 = eoprot_ID_get(eoprot_endpoint_management, eoprot_entity_mn_appl, 0, eoprot_tag_mn_appl_status); eOmn_appl_status_t *status = (eOmn_appl_status_t*)eoprot_variable_ramof_get(eoprot_board_localboard, id32); status->txdecimationfactor = txratedivider; eom_emsrunner_Set_TXdecimationFactor(eom_emsrunner_GetHandle(), txratedivider); }
extern eOresult_t eo_nvset_NV_Get(EOnvSet* p, eOnvID32_t id32, EOnv* thenv) { eOnvEP8_t ep8 = eoprot_ID2endpoint(id32); uint8_t brd = 0; // local, or 0, 1, 2, 3 ... eObool_t proxied = eobool_false; EOnv_rom_t* rom = NULL; uint8_t* ram = NULL; EOVmutexDerived* mtx2use = NULL; eOvoid_fp_cnvp_cropdesp_t onsay = NULL; if((NULL == p) || (NULL == thenv)) { return(eores_NOK_nullpointer); } brd = p->theboard.boardnum; // - verify that on the given endpoint there is a valid id32. if the id32 is not recognised, then ... eores_NOK_generic if(eobool_false == eoprot_id_isvalid(brd, id32)) { return(eores_NOK_generic); } // - retrieve from the device and endpoint what is required to form the netvar: con, ram, mtx, etc. // - 0+. proxied? proxied = eoprot_variable_is_proxied(brd, id32); // - 0++. the onsay function onsay = eoprot_onsay_endpoint_get(ep8); // - 1. the rom rom = (EOnv_rom_t*) eoprot_variable_romof_get(brd, id32); // - 2. the ram ram = (uint8_t*) eoprot_variable_ramof_get(brd, id32); // - 3. the mtx mtx2use = s_eo_nvset_get_nvmutex(p, id32); // - final control about the validity of id32. it may be redundant but it is safer. for instance if the fptr_isepidsupported() // does not take into account a removed tag and just checks that the tag-number is lower than the max allowed. if((NULL == rom) || (NULL == ram)) // mtx2use can be NULL { return(eores_NOK_generic); } // - load everything into the nv eo_nv_hid_Load( thenv, p->theboard.ipaddress, brd, proxied, id32, onsay, rom, ram, mtx2use ); return(eores_OK); }
extern void* eo_nvset_RAMofVariable_Get(EOnvSet* p, eOnvID32_t id32) { if((NULL == p)) { return(NULL); } return(eoprot_variable_ramof_get(p->theboard.boardnum, id32)); }
extern void eoprot_fun_UPDT_mn_appl_cmmnds_go2state(const EOnv* nv, const eOropdescriptor_t* rd) { eOmn_appl_state_t *go2state = (eOmn_appl_state_t *)nv->ram; eOprotID32_t id32 = eoprot_ID_get(eoprot_endpoint_management, eoprot_entity_mn_appl, 0, eoprot_tag_mn_appl_status); eOmn_appl_status_t *status = (eOmn_appl_status_t*)eoprot_variable_ramof_get(eoprot_board_localboard, id32); eOresult_t res = eores_NOK_generic; switch(*go2state) { case applstate_config: { res = eom_emsappl_ProcessGo2stateRequest(eom_emsappl_GetHandle(), eo_sm_emsappl_STcfg); // the new currstate is set inside the on-entry of the state machine //if(eores_OK == res) //{ // status->currstate = applstate_config; //} } break; case applstate_running: { uint32_t canBoardsReady = 0; uint32_t canBoardsChecked = 0; char str[60]; if(eobool_false == eo_appTheDB_areConnectedCanBoardsReady(eo_emsapplBody_GetDataBaseHandle(eo_emsapplBody_GetHandle()), &canBoardsReady, &canBoardsChecked)) { #warning marco.accame: put a dedicated diagnostics message with list of missing can boards snprintf(str, sizeof(str), "only 0x%x of of 0x%x.", canBoardsReady, canBoardsChecked); // the new currstate is set inside the on-entry of the state machine //status->currstate = applstate_error; // it MUST NOT be fatal error because we want to give the ems time to find the boards ready eo_errman_Error(eo_errman_GetHandle(), eo_errortype_error, str, "eoprot_fun_UPDT_mn_appl_cmmnds_go2state", &eo_errman_DescrUnspecified); return; // eo_errman_Error(eo_errman_GetHandle(), eo_errortype_error, str, "eoprot_fun_UPDT_mn_appl_cmmnds_go2state", &eo_errman_DescrUnspecified); } else { // marco.accame: if i send diagnostics messages just before going to running mode ... the application crashes. TO BE UNDERSTOOD WHY ! //eo_emsapplBody_SignalDetectedCANboards(eo_emsapplBody_GetHandle()); // // maybe in here we can put an info diagnostics message // // send message about the ready boards // uint8_t numcanboards = eo_appTheDB_GetNumberOfCanboards(eo_appTheDB_GetHandle()); // uint8_t i = 0; // eOappTheDB_board_canlocation_t loc = {0}; // eObrd_cantype_t exptype = eobrd_cantype_unknown; // eObrd_typeandversions_t detected = {0}; // // eOerrmanDescriptor_t des = {0}; // des.code = eoerror_code_get(eoerror_category_Debug, eoerror_value_DEB_tag07); // // for(i=0; i<numcanboards; i++) // { // if(eores_OK == eo_appTheDB_GetCanDetectedInfo(eo_appTheDB_GetHandle(), i, &loc, &exptype, &detected)) // { // // fill the message. so far i use a debug with can-id-typedetected-typeexpectde // des.sourcedevice = (eOcanport1 == loc.emscanport) ? (eo_errman_sourcedevice_canbus1) : (eo_errman_sourcedevice_canbus2); // des.sourceaddress = loc.addr; // des.param = (exptype << 8) | (detected.boardtype); // eo_errman_Error(eo_errman_GetHandle(), eo_errortype_info, NULL, NULL, &des); // } // } } res = eom_emsappl_ProcessGo2stateRequest(eom_emsappl_GetHandle(), eo_sm_emsappl_STrun); // the new currstate is set inside the on-entry of the state machine //if(eores_OK == res) //{ // status->currstate = applstate_running; //} } break; case applstate_error: { //I don't expect to receive go to error cmd res = eom_emsappl_ProcessGo2stateRequest(eom_emsappl_GetHandle(), eo_sm_emsappl_STerr); // the new currstate is set inside the on-entry of the state machine //if(eores_OK == res) //{ // status->currstate = applstate_error; //} } break; default: { } break; } }
static eOresult_t s_eo_nvset_NVsOfEP_Initialise(EOnvSet* p, eOnvset_ep_t* endpoint, eOnvEP8_t ep08) { eOnvset_brd_t* theBoard = NULL; eOnvset_ep_t* theEndpoint = endpoint; eOvoid_fp_uint32_voidp_t initialise = NULL; if(NULL == p) { return(eores_NOK_nullpointer); } theBoard = &p->theboard; if(NULL == theEndpoint) { theEndpoint = s_eo_nvset_get_endpoint(p, ep08); if(NULL == theEndpoint) { return(eores_NOK_generic); } // if(ep08 != theEndpoint->epcfg.endpoint) // { // return(eores_NOK_generic); // } } if(eobool_true == (theEndpoint->initted)) { // already initted return(eores_OK); } initialise = eoprot_endpoint_get_initialiser(ep08); if(NULL != initialise) { initialise(theBoard->ipaddress, theEndpoint->epram); } theEndpoint->initted = eobool_true; #define EO_NVSET_INIT_EVERY_NV #if defined(EO_NVSET_INIT_EVERY_NV) { // put parenthesis to create a new scope and avoid errors in non c99 environments as windows EOnv thenv = {0}; uint16_t k = 0; EOnv_rom_t* rom = NULL; uint8_t* ram = NULL; uint16_t nvars = theEndpoint->epnvsnumberof; eOipv4addr_t ip = theBoard->ipaddress; uint8_t brd = theBoard->boardnum; // local or 0, 1, 2, 3 eOnvID32_t id32 = EOK_uint32dummy; uint32_t prog = 0; eObool_t proxied = eobool_false; eOvoid_fp_cnvp_cropdesp_t onsay = NULL; EOVmutexDerived* mtx2use = NULL; if(eo_nvset_protection_one_per_board == p->protection) { mtx2use = theBoard->mtx_board; } else if(eo_nvset_protection_one_per_endpoint == p->protection) { mtx2use = theEndpoint->mtx_endpoint; } // else if eo_nvset_protection_one_per_netvar ... eval foreach k for(k=0; k<nvars; k++) { if(eo_nvset_protection_one_per_netvar == p->protection) { //#warning -> think of uint32 and void* maybe use uint64 uint32_t** addr = eo_vector_At(theEndpoint->themtxofthenvs, k); mtx2use = (EOVmutexDerived*) (*addr); } prog = k; // - 0. the id32 id32 = eoprot_endpoint_prognum2id(brd, ep08, prog); if(EOK_uint32dummy == id32) { continue; } // - 0+. proxied? proxied = eoprot_variable_is_proxied(brd, id32); // - 0++ onsay onsay = eoprot_onsay_endpoint_get(ep08); // - 1. the rom rom = (EOnv_rom_t*) eoprot_variable_romof_get(brd, id32); // - 2. the ram ram = (uint8_t*) eoprot_variable_ramof_get(brd, id32); // - 3. the mtx mtx2use = mtx2use; // - load everything into the nv eo_nv_hid_Load( &thenv, ip, brd, proxied, id32, onsay, rom, ram, mtx2use ); eo_nv_Init(&thenv); } } // put parenthesis to create a new scope and avoid errors in non c99 environments as windows #endif //EO_NVSET_INIT_EVERY_NV return(eores_OK); }