Ejemplo n.º 1
0
extern eOresult_t eo_transmitter_regular_rops_Refresh(EOtransmitter *p)
{
    if(NULL == p) 
    {
        return(eores_NOK_nullpointer);
    }  

    if(NULL == p->listofregropinfo)
    {
        // in such a case there is room for regular rops (for instance because the cfg->maxnumberofregularrops is zero)
        return(eores_OK);
    }
    
    eov_mutex_Take(p->mtx_regulars, eok_reltimeINFINITE);
    
    if(eobool_true == eo_list_Empty(p->listofregropinfo))
    {
        eov_mutex_Release(p->mtx_regulars);
        return(eores_OK);
    } 
    
    p->currenttime = eov_sys_LifeTimeGet(eov_sys_GetHandle());
    
    // for each element in the list ... i do: ... see function
    eo_list_ForEach(p->listofregropinfo, s_eo_transmitter_list_updaterop_in_ropframe, p);

    eov_mutex_Release(p->mtx_regulars);
    
    return(eores_OK);   
}
Ejemplo n.º 2
0
extern eOresult_t eo_candiscovery2_Stop(EOtheCANdiscovery2 *p)
{   
    if(NULL == p)
    {
        return(eores_NOK_nullpointer);
    }
    
    // there are four possible situations:
    // 1. all boards are found and they all have correct fw version: OK
    //    if we have this situation we are not in timeout expiry. 
    //    i must: stop the timer, send up a confirmation OK, reset status. 
    // 2. all boards are found but at least one has an incorrect fw version: NOK_allfound_fwerror
    //    if we have this situation we are not in timeout expiry. 
    //    i must: stop the timer, send up a confirmation NOK_allfound_fwerror, send up diagnostics with list of error in fw version, reset status.
    // 3. at least one board is not found. the ones found have correct fw version: NOK_notfound_fwok
    //    if we have this situation we are in timeout expiry.
    //    i must: stop the timer, send up a confirmation NOK_notfound_fwok, send up diagnostics with list of missing boards, reset status.
    // 4. at least one board is not found. at least one found have wrong fw version: NOK_notfound_fwko
    //    if we have this situation we are in timeout expiry.
    //    i must: stop the timer, send up a confirmation NOK_notfound_fwko, send up diagnostics with list of missing boards, send up diagnostics with list of error in fw version, reset status.    

    uint64_t endtime = eov_sys_LifeTimeGet(eov_sys_GetHandle());
    uint64_t delta = endtime - s_eo_thecandiscovery2.searchstatus.timeofstart;  
    delta /= 1000;
    s_eo_thecandiscovery2.detection.duration = (uint16_t)delta;    

#if defined(EOCANDISCOVERY2_TRACE)     
snprintf(s_trace_string, sizeof(s_trace_string), "EOtheCANdiscovery2: stop() after %d ms from start", (uint32_t)delta);
    hal_trace_puts(s_trace_string);
#endif    
    
//    uint8_t mode = 0; // 0 is ok, 1 is NOK_allfound_fwerror, 2 is NOK_notfound_fwok, 3 is NOK_notfound_fwko
    eObool_t allboardsareok = (eobool_false == s_eo_thecandiscovery2.detection.atleastonereplyisincompatible) ? (eobool_true) : (eobool_false);
    
    if((eobool_true == s_eo_thecandiscovery2.detection.allhavereplied) && (eobool_true == allboardsareok))
    {
        eo_timer_Stop(s_eo_thecandiscovery2.discoverytimer);
        s_eo_candiscovery2_sendDiagnosticsToHost(eobool_true, eobool_true); 
        s_eo_candiscovery2_resetSearchStatus();
    }
    else
    {
        eo_timer_Stop(s_eo_thecandiscovery2.discoverytimer);
        s_eo_candiscovery2_sendDiagnosticsToHost(s_eo_thecandiscovery2.detection.allhavereplied, allboardsareok);
        s_eo_candiscovery2_resetSearchStatus();        
    }
    
    // put it in heres, so that we can call a _Start() inside the callback ....
    if(NULL != s_eo_thecandiscovery2.onstop.function)
    {  
        eObool_t allisok = s_eo_thecandiscovery2.detection.allhavereplied && allboardsareok;
        s_eo_thecandiscovery2.onstop.function(s_eo_thecandiscovery2.onstop.parameter, &s_eo_thecandiscovery2, allisok);
    }
        
    return(eores_OK); 
}
Ejemplo n.º 3
0
extern eOresult_t eo_candiscovery2_Tick(EOtheCANdiscovery2 *p)
{
    if(NULL == p)
    {
        return(eores_NOK_nullpointer);
    }  
    
    // i execute only if the tick is enabled    
    if(eobool_false == s_eo_thecandiscovery2.searchstatus.tickingenabled)
    {
        return(eores_OK);
    }

    // i execute only if the search is enabled    
    if(eobool_false == s_eo_thecandiscovery2.searchstatus.searching)
    {
        return(eores_OK);
    } 

#if defined(EOCANDISCOVERY2_TRACE)    
    uint64_t now = eov_sys_LifeTimeGet(eov_sys_GetHandle());
    uint64_t delta = (now - s_eo_thecandiscovery2.searchstatus.timeofstart) / 1000;
    snprintf(s_trace_string, sizeof(s_trace_string), "EOtheCANdiscovery2: tick() after %d ms from start", (uint32_t)delta);
    hal_trace_puts(s_trace_string);
#endif
    
    // i check if there is a forced stop, which means that we have reached the max number of attempts
    if(eobool_true == s_eo_thecandiscovery2.searchstatus.forcestop)
    {   //  ... stop everything. the stop operation also sends up diagnostics or ack/nak
        return(eo_candiscovery2_Stop(p));
    }
    
    // otherwise i trigger a further search    
    s_eo_candiscovery2_search();
      

    return(eores_OK);
}
Ejemplo n.º 4
0
extern eOresult_t eo_transmitter_outpacket_Get(EOtransmitter *p, EOpacket **outpkt)
{
    uint16_t size;

    if((NULL == p) || (NULL == outpkt)) 
    {
        return(eores_NOK_nullpointer);
    }

    // now add the age of the frame
    eo_ropframe_age_Set(p->ropframereadytotx, eov_sys_LifeTimeGet(eov_sys_GetHandle()));
    
    // add sequence number

    p->tx_seqnum++;
    eo_ropframe_seqnum_Set(p->ropframereadytotx, p->tx_seqnum);

    // now set the size of the packet according to what is inside the ropframe.
    eo_ropframe_Size_Get(p->ropframereadytotx, &size);
    eo_packet_Size_Set(p->txpacket, size);

#if defined(USE_DEBUG_EOTRANSMITTER)    
    {   // DEBUG    
        uint16_t capacity = 0;
        eo_packet_Capacity_Get(p->txpacket, &capacity);   
        if(size > capacity)
        {
            p->debug.txropframeistoobigforthepacket ++;
        }
    }
#endif
    
    // finally gives back the packet
    *outpkt = p->txpacket;
    
    return(eores_OK);   
}
Ejemplo n.º 5
0
extern void eom_emsapplcfg_hid_userdef_OnError(eOerrmanErrorType_t errtype, const char *info, eOerrmanCaller_t *caller, const eOerrmanDescriptor_t *des)
{
    const char empty[] = "EO?";
    const char *err = eo_errman_ErrorStringGet(eo_errman_GetHandle(), errtype);
    char str[128];
    EOMtheEMSapplCfg *emsapplcfg = eom_emsapplcfg_GetHandle();
    
    const char *eobjstr = (NULL != caller) ? (caller->eobjstr) : (empty);
    uint32_t taskid = (NULL != caller) ? (caller->taskid) : (0);

    if(emsapplcfg->errmng_haltrace_enabled)
    {
        snprintf(str, sizeof(str), "[%s] %s in tsk %d: %s", err, eobjstr, taskid, info);
        hal_trace_puts(str);
    }
    if(errtype <= eo_errortype_error)
    {
        return;
    }
    
    eov_sys_Stop(eov_sys_GetHandle());
    
    // init leds
    overridden_appl_led_error_init();
    
    // compute the mask of led to be toggled.
    uint8_t ledmask = 0xff;    
    if((NULL != caller) && (NULL != caller->eobjstr))
    {
        if(0 == strcmp(caller->eobjstr, "HAL"))
        {
            hl_bits_byte_bitclear(&ledmask, 0);           
        }
        else if(0 == strcmp(caller->eobjstr, "OSAL"))
        {
            hl_bits_byte_bitclear(&ledmask, 1);  
        }
        else if(0 == strcmp(caller->eobjstr, "IPAL"))
        {
            hl_bits_byte_bitclear(&ledmask, 2);  
        }
    }

    for(;;)
    {
        hal_sys_delay(100);
        
        if(hl_true == hl_bits_byte_bitcheck(ledmask, 0))
        {
            hal_led_toggle(hal_led0);
        }
        if(hl_true == hl_bits_byte_bitcheck(ledmask, 1))
        {
            hal_led_toggle(hal_led1);
        }
        if(hl_true == hl_bits_byte_bitcheck(ledmask, 2))
        {            
            hal_led_toggle(hal_led2);
        }
        
        hal_led_toggle(hal_led3);
        hal_led_toggle(hal_led4);
        hal_led_toggle(hal_led5);        
    }
}
Ejemplo n.º 6
0
extern eOresult_t eo_candiscovery2_OneBoardIsFound(EOtheCANdiscovery2 *p, eObrd_canlocation_t loc, eObool_t match, eObrd_info_t *detected)
{   
    if((NULL == p) || (NULL == detected))
    {
        return(eores_NOK_nullpointer);
    }
    
    // use the information inside loc to mark that a can board has replied. 
    eo_common_hlfword_bitset(&s_eo_thecandiscovery2.detection.replies[loc.port], loc.addr);
    // put inside detected what the board has told
    memcpy(&s_eo_thecandiscovery2.detection.boards[loc.port][loc.addr].info, detected, sizeof(eObrd_info_t)); 
    // set the rx time
    s_eo_thecandiscovery2.detection.boards[loc.port][loc.addr].time = (eov_sys_LifeTimeGet(eov_sys_GetHandle()) - s_eo_thecandiscovery2.searchstatus.timeofstart)/1000;
    // now mark success or failure of the query. the success depends on what we want to do with board-type, prot-version, appl-version.
    // so far we use the strict rule: 
    // - the board must be the same, 
    // - the prot-version must be the same (if the expected is not 0.0), 
    // - the appl-version must be the same (if the expected is not 0.0).
    eObool_t itisok = s_eo_candiscovery2_IsDetectionOK(p, loc, match, detected);
    // mark a failure
    if(eobool_false == itisok)
    {
        s_eo_thecandiscovery2.detection.atleastonereplyisincompatible = eobool_true;
        eo_common_hlfword_bitset(&s_eo_thecandiscovery2.detection.incompatibilities[loc.port], loc.addr);
    }
    
    // now i verify if every board i was looking for has replied. if so, i can stop procedure.    
    s_eo_thecandiscovery2.detection.allhavereplied = s_eo_candiscovery2_AllBoardsAreFound(p);
    
#if defined(EOCANDISCOVERY2_TRACE)     
    snprintf(s_trace_string, sizeof(s_trace_string), "EOtheCANdiscovery2: FOUND board at CAN%d ID%d after %d ms from start", loc.port+1, loc.addr, s_eo_thecandiscovery2.detection.boards[loc.port][loc.addr].time);
    hal_trace_puts(s_trace_string);
#endif
    
    if(eobool_true == s_eo_thecandiscovery2.detection.allhavereplied)
    {
        eo_candiscovery2_Stop(p);
    }

    return(eores_OK);
}
Ejemplo n.º 7
0
extern eOresult_t eo_candiscovery2_Start(EOtheCANdiscovery2 *p, const eOcandiscovery_target_t *target, eOcandiscovery_onstop_t* onstop)
{
    if((NULL == p) || (NULL == target))
    {
        return(eores_NOK_nullpointer);
    }  
    
    
    // if a search is active, i must call the stop
    if(eobool_true == s_eo_thecandiscovery2.searchstatus.searching)
    {
        eo_candiscovery2_Stop(p);
    }
    
    
    // reset target of previous search
    s_eo_candiscovery2_resetTarget();
    s_eo_candiscovery2_resetDetection();
    
    // reset search status
    s_eo_candiscovery2_resetSearchStatus();
    
        
    // copy the new target of boards
    memcpy(&s_eo_thecandiscovery2.target, target, sizeof(eOcandiscovery_target_t));    
    
    // copy onstop
    memcpy(&s_eo_thecandiscovery2.onstop, onstop, sizeof(eOcandiscovery_onstop_t));
    
    // now start the procedure
    s_eo_thecandiscovery2.searchstatus.searching = eobool_true;
    s_eo_thecandiscovery2.searchstatus.tickingenabled = eobool_false;
    s_eo_thecandiscovery2.searchstatus.forcestop = eobool_false;
    s_eo_thecandiscovery2.detection.atleastonereplyisincompatible = eobool_false;
    s_eo_thecandiscovery2.detection.allhavereplied = eobool_false;
    s_eo_thecandiscovery2.searchstatus.timeofstart = eov_sys_LifeTimeGet(eov_sys_GetHandle());
    
#if defined(EOCANDISCOVERY2_TRACE)
    uint64_t start = s_eo_thecandiscovery2.searchstatus.timeofstart/1000;
    snprintf(s_trace_string, sizeof(s_trace_string), "EOtheCANdiscovery2: starts @ lifetime %d ms", (uint32_t)start);
    hal_trace_puts(s_trace_string);
#endif


    s_eo_candiscovery2_start();
    
    if(eobool_false == s_eo_thecandiscovery2.detection.allhavereplied)
    {
    
        EOaction_strg astg = {0};
        EOaction *action = (EOaction*)&astg;
           
        // the action depends on the state of the application. 
        // if we are in config mode, then we send an event to the config task.  
        // else if we are in run mode we just set an enable flag for teh control-loop to exec _Tick().
        
        eo_action_SetCallback(action, s_eo_candiscovery2_on_timer_expiry, p, eov_callbackman_GetTask(eov_callbackman_GetHandle()));
        eo_timer_Start(s_eo_thecandiscovery2.discoverytimer, eok_abstimeNOW, s_eo_thecandiscovery2.config.period, eo_tmrmode_FOREVER, action);         
    }
    
    return(eores_OK);
}