Beispiel #1
0
//--------------------------------------------------------------------------------------------------
void simTest_SimPowerUpDown
(
    void
)
{
    le_sim_States_t  state;
    le_sim_Id_t simId;
    le_result_t res;
    le_clk_Time_t timeOut;

    //set timeout seconds for waiting for asynchronous power down event.
    timeOut.sec = 5;
    timeOut.usec = 0;

    SimPowerCycleSemaphore = le_sem_Create("HandlerSimPowerCycle", 0);

    SimPowerCycleThreadRef= le_thread_Create("ThreadSimPowerCycle", SimPowerCycleIndThread, NULL);

    le_thread_Start(SimPowerCycleThreadRef);

    // get blocked here until our event handler is registered and powerCycle thread is running
    res = le_sem_WaitWithTimeOut(SimPowerCycleSemaphore, timeOut);
    LE_ASSERT_OK(res);

    // Power down cases
    simId = le_sim_GetSelectedCard();
    state = le_sim_GetState(simId);
    LE_INFO("test: SIM state %d", state);
    LE_ASSERT(LE_SIM_READY == state);
    LE_ASSERT_OK(le_sim_SetPower(simId, LE_OFF));

    // Wait for complete asynchronous event of powered down (LE_SIM_POWER_DOWN)
    res = le_sem_WaitWithTimeOut(SimPowerCycleSemaphore, timeOut);
    LE_ASSERT_OK(res);
    LE_INFO("Powers Down current SIM: success");

    // Power up cases
    LE_ASSERT_OK(le_sim_SetPower(simId, LE_ON));
    // Wait for complete asynchronous event of powered up  (LE_SIM_READY)
    res = le_sem_WaitWithTimeOut(SimPowerCycleSemaphore, timeOut);
    LE_ASSERT_OK(res);
    LE_INFO("Powers On current SIM: success");

    // Remove the handler
    le_sim_RemoveNewStateHandler(SimPowerCycleHdlrRef);

    // cancel the power cycle test thread
    le_thread_Cancel(SimPowerCycleThreadRef);
}
Beispiel #2
0
//--------------------------------------------------------------------------------------------------
static void RemoveHandler
(
    void* param1Ptr,
    void* param2Ptr
)
{
    AppContext_t * appCtxPtr = (AppContext_t*) param1Ptr;

    le_sim_RemoveNewStateHandler( appCtxPtr->statHandler );

    le_sim_RemoveSimToolkitEventHandler( appCtxPtr->stkHandler );

    // Semaphore is used to synchronize the task execution with the core test
    le_sem_Post(ThreadSemaphore);
}