Beispiel #1
0
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);
}
Beispiel #2
0
static eOresult_t s_eo_nvset_DeinitEPs(EOnvSet* p)
{
    eOnvset_brd_t* theBoard = &p->theboard;   
    uint16_t i = 0;  
    uint16_t endpointsnum = 0;
    
    if(NULL == theBoard->theendpoints)
    {   // already deinitted
        return(eores_OK);
    }
   
    endpointsnum = eo_vector_Size(theBoard->theendpoints);
 
    for(i=0; i<endpointsnum; i++)
    {
        eOnvset_ep_t **ppep = (eOnvset_ep_t **)eo_vector_At(theBoard->theendpoints, i);
        eOnvset_ep_t *theEndpoint = *ppep;
        
        // now i erase memory associated with this endpoint
        eo_mempool_Delete(eo_mempool_GetHandle(), theEndpoint->epram);
        // and i dissociates that from from the internals of the eoprot library
        eoprot_config_endpoint_ram(theBoard->boardnum, theEndpoint->epcfg.endpoint, NULL, 0);
        // i also de-init the number of entities for that endpoint
        eoprot_config_endpoint_entities(theBoard->boardnum, theEndpoint->epcfg.endpoint, NULL);
        
        // now i delete all data associated to the mutex protection
        
        if(NULL != theEndpoint->mtx_endpoint)
        {
            eov_mutex_Delete(theEndpoint->mtx_endpoint);
        }
        if(NULL != theEndpoint->themtxofthenvs)
        {
            uint16_t size = eo_vector_Size(theEndpoint->themtxofthenvs);
            int j = 0;
            for(j=0; j<size; j++)
            {
                EOVmutexDerived** pmtx =  (EOVmutexDerived**)eo_vector_At(theEndpoint->themtxofthenvs, j);
                eov_mutex_Delete(*pmtx);            
            } 
            eo_vector_Delete(theEndpoint->themtxofthenvs);
        }
   
        // now i erase the memory of the entire eOnvset_ep_t entry        
        eo_mempool_Delete(eo_mempool_GetHandle(), theEndpoint);       
    }
    
    // so that we dont get in here inside again
    theBoard->theendpoints = NULL;

    return(eores_OK);
}
Beispiel #3
0
extern eOresult_t eo_nvset_LoadEP(EOnvSet* p, eOprot_EPcfg_t *cfgofep, eObool_t initNVs)
{
    eOnvset_brd_t* theBoard = NULL;
    eOnvBRD_t brd = 0;      // local or 0, 1, 2, etc.
    eOnvset_ep_t *theEndpoint = NULL;
    uint16_t epnvsnumberof = 0;  
    uint16_t sizeofram =0;
 
    if((NULL == p) || (NULL == cfgofep)) 
    {
        return(eores_NOK_nullpointer); 
    }
        
        
    theBoard = &p->theboard;
    brd = p->theboard.boardnum;
        
    theEndpoint = eo_mempool_New(eo_mempool_GetHandle(), 1*sizeof(eOnvset_ep_t));
    
    memcpy(&theEndpoint->epcfg, cfgofep, sizeof(eOprot_EPcfg_t));   
    
    // ok, now in theEndpoint->epcfg.numberofsentities[] we have some ram. we use it to load the protocol.
    eoprot_config_endpoint_entities(brd, theEndpoint->epcfg.endpoint, theEndpoint->epcfg.numberofentities);
    // now it is ok to compute the size of the endpoint using the proper protocol function
    sizeofram = eoprot_endpoint_sizeof_get(brd, theEndpoint->epcfg.endpoint); 
    
    // now that i have loaded  the number of entities i verify if they are ok by checking the number of variables in the endpoint.
    epnvsnumberof = eoprot_endpoint_numberofvariables_get(brd, cfgofep->endpoint);   
    if(0 == epnvsnumberof)
    {
        //#warning TBD: see how we continue in here ....
        char str[64] = {0};
        snprintf(str, sizeof(str), "EOnvSet: ep %d has 0 nvs", cfgofep->endpoint);  
        eo_errman_Error(eo_errman_GetHandle(), eo_errortype_error, str, NULL, &eo_errman_DescrRuntimeErrorLocal); 
        
        eoprot_config_endpoint_entities(brd, theEndpoint->epcfg.endpoint, NULL);
        eo_mempool_Delete(eo_mempool_GetHandle(), theEndpoint); 
        
        return(eores_NOK_generic); 
    }  
    
    theEndpoint->epnvsnumberof      = epnvsnumberof;
    theEndpoint->initted            = eobool_false;    
    theEndpoint->epram              = eo_mempool_GetMemory(eo_mempool_GetHandle(), eo_mempool_align_auto, sizeofram, 1);
    theEndpoint->mtx_endpoint       = (eo_nvset_protection_one_per_endpoint == p->protection) ? p->mtxderived_new() : NULL;
        
    // now we must load the ram in the endpoint
    eoprot_config_endpoint_ram(brd, theEndpoint->epcfg.endpoint, theEndpoint->epram, sizeofram);
    
    // now add the vector of mtx if needed.
    if(eo_nvset_protection_one_per_netvar == p->protection)
    {
        uint16_t i;
        theEndpoint->themtxofthenvs = eo_vector_New(sizeof(EOVmutexDerived*), epnvsnumberof, NULL, 0, NULL, NULL);
        for(i=0; i<epnvsnumberof; i++)
        {
            EOVmutexDerived* mtx = p->mtxderived_new();
            eo_vector_PushBack(theEndpoint->themtxofthenvs, &mtx);           
        }
    }
    
    // now, i must update the mapping function from ep value to vector of endpoints  
    theBoard->ep2indexlut[theEndpoint->epcfg.endpoint] = eo_vector_Size(theBoard->theendpoints);
    // and only now i push back the endpoint
    eo_vector_PushBack(theBoard->theendpoints, &theEndpoint);
    
    
    if(eobool_true == initNVs)
    {
        s_eo_nvset_NVsOfEP_Initialise(p, theEndpoint, theEndpoint->epcfg.endpoint); 
    }

    return(eores_OK);
}