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);
}
extern EOMtheEMSdiscoverylistener * eom_emsdiscoverylistener_Initialise(const eOemsdiscoverylistener_cfg_t *cfg)
{
    if(NULL != s_emsdiscoverylistener_singleton.task)
    {
        return(&s_emsdiscoverylistener_singleton);
    }
    
    if(NULL == cfg)
    {
        cfg = &eom_emsdiscoverylistener_DefaultCfg;
    }
    
    memcpy(&s_emsdiscoverylistener_singleton.cfg, cfg, sizeof(eOemsdiscoverylistener_cfg_t));
    
    
    if(NULL == eom_ipnet_GetHandle())
    {
        eo_errman_Error(eo_errman_GetHandle(), eo_errortype_fatal, "eom_emsdiscoverylistener_Initialise(): EOMtheIPnet not started yet", s_eobj_ownname, &eo_errman_DescrRuntimeErrorLocal);
    }

    // create the socket    
    s_emsdiscoverylistener_singleton.socket = eo_socketdtg_New(cfg->inpdatagramnumber, cfg->inpdatagramsizeof, (eobool_true == cfg->usemutex) ? (eom_mutex_New()) : (NULL), 
                                                               cfg->outdatagramnumber, cfg->outdatagramsizeof, (eobool_true == cfg->usemutex) ? (eom_mutex_New()) : (NULL)
                                                              );    
    // create the rx packet
    s_emsdiscoverylistener_singleton.rxpkt = eo_packet_New(cfg->inpdatagramsizeof);
    
    
    // initialise the transceiver
    eOemsdiscoverytransceiver_cfg_t dtrcfg;
    dtrcfg.hostipv4addr  = cfg->remoteipaddr;
    dtrcfg.hostipv4port  = cfg->remoteport;
    dtrcfg.txpktcapacity = cfg->outdatagramsizeof;
    dtrcfg.discoveryprotocol = cfg->discoveryprotocol;
    dtrcfg.dbgshutdowntime = 0; // if 0 the shutdown timer is not started. otherwise it forces a got to updater. 3*60*eok_reltime1sec;
    eom_emsdiscoverytransceiver_Initialise(&dtrcfg);
    
    
    // create the task
    s_emsdiscoverylistener_singleton.task = eom_task_New(eom_mtask_EventDriven, cfg->taskpriority, cfg->taskstacksize, 
                                                    s_eom_emsdiscoverylistener_task_startup, s_eom_emsdiscoverylistener_task_run,  
                                                    (eOevent_t)0, eok_reltimeINFINITE, NULL, 
                                                    tskEMScfg, "tskEMSlis");
 
                                                   
    
    return(&s_emsdiscoverylistener_singleton);
}