Ejemplo n.º 1
0
static void s_cangateway_startup(EOMtask *p, uint32_t t)
{
    char str[96];
 

    // initialise the socket
    // up to 16 packets of 64 bytes ...    
    eupdater_sock_cangateway = eo_socketdtg_New (   16, eupdater_cangtw_udp_packet_maxsize, eom_mutex_New(), // input queue
                                                    16, eupdater_cangtw_udp_packet_maxsize, eom_mutex_New()  // output queue
                                                );
   

    snprintf(str, sizeof(str), "opening a txrx socket on port %d for can gateway\n\r", s_cangtw_port);
    hal_trace_puts(str);

    EOaction_strg action_strg;
    EOaction* act = (EOaction*)&action_strg;  
    // set the rx action on socket to be an event s_event_cangtw_sock_rec to this task object
    eo_action_SetEvent(act, event_cangtw_sock_rec, p);
    eo_socketdtg_Open(eupdater_sock_cangateway, s_cangtw_port, eo_sktdir_TXRX, eobool_false, NULL, act, NULL);
    
    // init and start the sm. also pass to it the task and teh socket 
    s_sm_cangtw = eo_sm_New(eo_cfg_sm_cangtw_Get());
    eo_sm_Start(s_sm_cangtw);
    eOsmDynamicDataCanGtw_t* smdata = (eOsmDynamicDataCanGtw_t*) eo_sm_GetDynamicData(s_sm_cangtw); 
    smdata->taskCANgtw = eupdater_task_cangateway;
    smdata->sockCANgtw = eupdater_sock_cangateway; 

    // ok, now the startup is over.
    osal_semaphore_increment(startup_done_semaphore, osal_callerTSK);
}
static void s_eom_emsdiscoverylistener_task_startup(EOMtask *p, uint32_t t)
{
    // open the socket
    EOaction_strg astg = {0};
    EOaction *onrx = (EOaction*)&astg;
    eo_action_SetEvent(onrx, emsdiscoverylistener_evt_packet_received, p);
    
    eo_socketdtg_Open(s_emsdiscoverylistener_singleton.socket, s_emsdiscoverylistener_singleton.cfg.localport, eo_sktdir_TXRX, eobool_false, 
                      NULL, onrx, NULL);   
    
    eo_errman_Trace(eo_errman_GetHandle(), "called _task_startup()", s_eobj_ownname);
                                
}