Пример #1
0
static void s_cangateway_run(EOMtask *p, uint32_t t)
{
    eOevent_t evt = (eOevent_t) t;
    
#if defined(_DEBUG_MODE_FULL_)    
    char str[128];
    snprintf(str, sizeof(str), "received event %d", evt);
    hal_trace_puts(str);      
#endif    
    
    if(eobool_true == eo_common_event_check(evt, event_cangtw_start))
    {
        eo_sm_ProcessEvent(s_sm_cangtw, eo_sm_cangtw_evstart);        
    }

    if(eobool_true == eo_common_event_check(evt, event_cangtw_blmsg1))
    {
        eo_sm_ProcessEvent(s_sm_cangtw, eo_sm_cangtw_evcanblmsg1);        
    }    

    if(eobool_true == eo_common_event_check(evt, event_cangtw_blmsg2))
    {
        eo_sm_ProcessEvent(s_sm_cangtw, eo_sm_cangtw_evcanblmsg2);        
    } 
    
    if(eobool_true == eo_common_event_check(evt, event_cangtw_go2run))
    {
        eo_sm_ProcessEvent(s_sm_cangtw, eo_sm_cangtw_evgo2run);        
    }
    
    if(eobool_true == eo_common_event_check(evt, event_cangtw_sock_rec))
    {
        eo_sm_ProcessEvent(s_sm_cangtw, eo_sm_cangtw_evrxeth);        
    }
    
    if(eobool_true == eo_common_event_check(evt, event_cangtw_can1_rec))
    {
        eo_sm_ProcessEvent(s_sm_cangtw, eo_sm_cangtw_evrxcan1);        
    }    
    
    if(eobool_true == eo_common_event_check(evt, event_cangtw_can2_rec))
    {
        eo_sm_ProcessEvent(s_sm_cangtw, eo_sm_cangtw_evrxcan2);        
    }  
  
}
static void s_eom_emsdiscoverylistener_task_run(EOMtask *p, uint32_t t)
{
    // the event that we have received
    eOevent_t evt = (eOevent_t)t;
    EOpacket* rxpkt = s_emsdiscoverylistener_singleton.rxpkt;
    EOpacket* replypkt = NULL;
    eOsizecntnr_t remainingrxpkts = 0;    

    
    if(eobool_true == eo_common_event_check(evt, emsdiscoverylistener_evt_packet_received))
    {   // process the reception of a packet. it must contain a frame with a particular protocol
        
    
        // 1. get the packet.    
        if(eores_OK == eo_socketdtg_Get(s_emsdiscoverylistener_singleton.socket, rxpkt, eok_reltimeZERO))
        {
                 
            // 2. process the packet with the transceiver
            if(eores_OK == eom_emsdiscoverytransceiver_Parse(eom_emsdiscoverytransceiver_GetHandle(), rxpkt))
            {
             
                // 3. retrieve the reply                
                if(eores_OK == eom_emsdiscoverytransceiver_GetReply(eom_emsdiscoverytransceiver_GetHandle(), &replypkt))
                {
                    // 4.  send a packet back. but only if the get_reply gave us a good one.
                    s_eom_emsdiscoverylistener_Transmit(&s_emsdiscoverylistener_singleton, replypkt);
                }
                
            }
        }
        
    
        // 5. if another packet is in the rx fifo, send a new event to process its retrieval again   
        eo_socketdtg_Received_NumberOf(s_emsdiscoverylistener_singleton.socket, &remainingrxpkts);
        
        if(remainingrxpkts > 0)
        {
            eom_task_SetEvent(p, emsdiscoverylistener_evt_packet_received); 
        }
        
    }
     
}