コード例 #1
0
ファイル: tempTest.c プロジェクト: mbarazzouq/legato-af
static void* DisplayTempThread(void* context)
{
    int32_t radioTemp = 0;
    int32_t platformTemp = 0;

    le_temp_ConnectService();

    LE_INFO("Thread Start");

    do
    {
        if (PoolTemp == 2)
        {
            le_temp_GetRadioTemperature(&radioTemp);
            le_temp_GetPlatformTemperature(&platformTemp);
            LE_INFO("(%d) Get Radio Temp (%d), Platform Temp %d",
                TimeCounter++, radioTemp, platformTemp);
            TimeCounter++;
        }
        sleep(1);
    }
    while (PoolTemp > 0);

    // Run the event loop
    le_event_RunLoop();
    return NULL;
}
コード例 #2
0
//--------------------------------------------------------------------------------------------------
static void* CellNetThread
(
    void* contextPtr
)
{
    // Connect to the services required by this thread
    le_cfg_ConnectService();
    le_mrc_ConnectService();
    le_sim_ConnectService();

    LE_INFO("CellNet Thread Started");

    // Register for command events
    le_event_AddHandler("ProcessCommand",
                        CommandEvent,
                        ProcessCommand);


    // Register for SIM state changes
    le_sim_AddNewStateHandler(SimStateHandler, NULL);

    // Register for MRC Network Registration state changes
    le_mrc_AddNetRegStateEventHandler(MrcNetRegHandler, NULL);


    // Run the event loop
    le_event_RunLoop();
    return NULL;
}
コード例 #3
0
ファイル: _le_main.c プロジェクト: andreasanna/legato-af
int main(int argc, char* argv[])
{
    arg_SetArgs((size_t)argc, (char**)argv);

    LE_DEBUG("== Starting Executable '%s' ==", STRINGIZE(LE_EXECUTABLE_NAME));

    LE_LOG_SESSION = log_RegComponent( STRINGIZE(LE_COMPONENT_NAME), &LE_LOG_LEVEL_FILTER_PTR);

    // Connect to the Log Control Daemon.
    // The sooner we can connect to the Log Control Daemon, the better, because that is when
    // we obtain any non-default log settings that have been set using the interactive log
    // control tool.  However, we can't do that until we have a working IPC messaging system.
    // However, the Log Control Daemon shouldn't try to connect to itself.
    // Also, the Service Directory shouldn't try to use the messaging system, so it can't
    // connect to the Log Control Daemon either.  Besides, the Service Directory starts before
    // the Log Control Daemon starts.
    #ifndef NO_LOG_CONTROL
        log_ConnectToControlDaemon();
    #endif

    //@todo: Block all signals that the user intends to handle with signal events.

    // Queue up all the component initialization functions to be called by the Event Loop after
    // it processes any messages that were received from the Log Control Daemon.
    event_QueueComponentInit(_le_event_InitializeComponent);


    LE_DEBUG("== Starting Event Processing Loop ==");

    le_event_RunLoop();

    LE_FATAL("SHOULDN'T GET HERE!");
}
コード例 #4
0
//--------------------------------------------------------------------------------------------------
static void* TestThread
(
    void* context
)
{
    le_atClient_ConnectService();

    UnsolCmtiRef = le_atClient_AddUnsolicitedResponseHandler(  "+CMTI:",
                                                DevRef,
                                                UnsolicitedResponseHandler,
                                                NULL,
                                                1
                                            );

    le_atClient_AddUnsolicitedResponseHandler(  "+COPS:",
                                                DevRef,
                                                UnsolicitedResponseHandler,
                                                NULL,
                                                1
                                            );

    le_event_RunLoop();

    return NULL;
}
コード例 #5
0
// A thread "main" function which creates a series of sems.
static void* ThreadCreateSem
(
    void* context
)
{
    char semNameBuffer[LIMIT_MAX_SEMAPHORE_NAME_BYTES] = {0};


    LE_INFO("Thread [%s] has started. Waiting on a semaphore.", le_thread_GetMyName());

    le_mutex_Lock(SemIndexMutexRef);

    snprintf(semNameBuffer, LIMIT_MAX_SEMAPHORE_NAME_BYTES, "[%s]Sem%ld",
             le_thread_GetMyName(), SemCreateIdx);

    le_sem_Ref_t sem = le_sem_Create(semNameBuffer, 0);

    SemRefArray[SemCreateIdx] = (SemRef_t){le_thread_GetCurrent(), sem};

    SemCreateIdx++;

    le_mutex_Unlock(SemIndexMutexRef);

    LE_INFO("In thread [%s], about to wait sem", le_thread_GetMyName());

    // notify the calling thread that this thread is about to wait on its sema.
    le_sem_Post(SemaRef);

    le_sem_Wait(sem);
    LE_INFO("In thread [%s], sema is posted", le_thread_GetMyName());

    le_event_RunLoop();
    return NULL;
}
コード例 #6
0
ファイル: eCallStress.c プロジェクト: H-H-bin/legato-af
//--------------------------------------------------------------------------------------------------
static void* ECallLoopThread
(
    void* ctxPtr
)
{
    le_ecall_ConnectService();

    while(1)
    {
        LE_INFO("Wait for semaphore...");
        le_sem_Wait(ThreadSemaphore);
        sleep(1);

        if (LastECallState == LE_ECALL_STATE_STARTED)
        {
            LE_INFO("Take the semaphore, End eCall...");
            LE_ASSERT(le_ecall_End(MytECallRef) == LE_OK);
            le_ecall_Delete(MytECallRef);
            MytECallRef = NULL;
        }
        else if (LastECallState == LE_ECALL_STATE_DISCONNECTED)
        {
            TestCount++;
            LE_INFO("Take the semaphore, Start new eCall...");

            LE_ASSERT((MytECallRef=le_ecall_Create()) != NULL);
            LE_ASSERT(le_ecall_SetMsdPosition(MytECallRef, true, +48898064, +2218092, 0) == LE_OK);
            LE_ASSERT(le_ecall_SetMsdPassengersCount(MytECallRef, 3) == LE_OK);
            LE_ASSERT(le_ecall_StartTest(MytECallRef) == LE_OK);
            LE_INFO("Start eCall #%d", TestCount);
        }
    }

    le_event_RunLoop();
}
コード例 #7
0
static void* Thread2(void* context)
{
    le_sig_SetEventHandler(SIGUSR2, SigUser2Handler);

    le_event_RunLoop();

    return NULL;
}
コード例 #8
0
// A thread function that attempts to wait on the semaphore passed in as context.
static void* WaitOnSem
(
    void* context
)
{
    le_sem_Ref_t sem = (le_sem_Ref_t)context;
    le_sem_Wait(sem);
    le_event_RunLoop();
    return NULL;
}
コード例 #9
0
ファイル: le_smsTest.c プロジェクト: schtipoun/legato-af
static void* MyRxThread
(
    void* context   ///< See parameter documentation above.
)
{
    le_sms_ConnectService();

    RxHdlrRef = le_sms_AddRxMessageHandler(TestRxHandler, context);

    le_event_RunLoop();
    return NULL;
}
コード例 #10
0
// -------------------------------------------------------------------------------------------------
static void* TestCellNetService
(
    void* contextPtr
)
{
    SwitchOnCellNet();

    LE_INFO("Verify that Cellular Network is ON by checking CellNet events.");

    // Run the event loop
    le_event_RunLoop();
    return NULL;
}
コード例 #11
0
ファイル: voiceCallTest.c プロジェクト: tegoo/legato-af
static void* HandlerThread(void* contextPtr)
{

    // Connect to the services required by this thread
    le_voicecall_ConnectService();
    le_audio_ConnectService();

    // Add voice call event handler function.
    VoiceCallHandlerRef = le_voicecall_AddStateHandler(MyCallEventHandler, contextPtr );

    le_event_RunLoop();
    return NULL;
}
コード例 #12
0
ファイル: main.c プロジェクト: H-H-bin/legato-af
//--------------------------------------------------------------------------------------------------
static void* TempThread
(
    void* ctxPtr
)
{
    pa_temp_Init();

    le_temp_Init();

    le_sem_Post(ThreadSemaphore);

    le_event_RunLoop();
}
コード例 #13
0
ファイル: main.c プロジェクト: legatoproject/legato-af
//--------------------------------------------------------------------------------------------------
static void* AsyncStartStopSessionThread
(
    void* contextPtr
)
{
    StartStopAsyncFunc_t startStopAsyncFunc = contextPtr;

    startStopAsyncFunc(ProfileRef[0], SessionHandlerFunc, NULL);

    // Run the event loop
    le_event_RunLoop();

    return NULL;
}
コード例 #14
0
static void* Thread1(void* context)
{
    delEvent = le_event_CreateId("DeleteSigs", 0);
    le_event_AddHandler("DelSigHandler", delEvent, DeleteSigs);

    le_sig_SetEventHandler(SIGUSR1, SigUser1Handler);

    // Start the test procedure by sending a SIGUSR1 signal to our own process.
    checkCount++;
    LE_ASSERT(kill(getpid(), SIGUSR1) == 0);

    le_event_RunLoop();

    return NULL;
}
コード例 #15
0
ファイル: gnssTest.c プロジェクト: hongbinz/legato-af
//--------------------------------------------------------------------------------------------------
static void* PositionThread
(
    void* context
)
{

    le_gnss_ConnectService();

    LE_INFO("======== Position Handler thread  ========");
    PositionHandlerRef = le_gnss_AddPositionHandler(PositionHandlerFunction, NULL);
    LE_ASSERT((PositionHandlerRef != NULL));

    le_event_RunLoop();
    return NULL;
}
コード例 #16
0
ファイル: le_ecallTest.c プロジェクト: ekral85/legato-af
//--------------------------------------------------------------------------------------------------
static void* Test_thread(void* context)
{

    le_ecall_StateChangeHandlerRef_t   stateChangeHandlerRef = 0x00;

    le_ecall_ConnectService();


    LE_INFO("Add State Change Handler");
    LE_ASSERT((stateChangeHandlerRef = le_ecall_AddStateChangeHandler(MyECallEventHandler, NULL)) != NULL);

    LE_INFO("No event loop");
    le_event_RunLoop();

}
コード例 #17
0
ファイル: tempTest.c プロジェクト: mbarazzouq/legato-af
/*
 * Event Thread
 */
static void* EventThread(void* context)
{
    le_temp_ThresholdEventHandlerRef_t ref;

    le_temp_ConnectService();

    ref = le_temp_AddThresholdEventHandler(ThresholdEventHandlerFunc, NULL);
    LE_ASSERT(ref != NULL);
    LE_INFO("ref  0x%p", ref);

    LE_INFO("EventThread Start");

    // Run the event loop
    le_event_RunLoop();
    return NULL;
}
コード例 #18
0
ファイル: le_smsTest.c プロジェクト: schtipoun/legato-af
static void* MyTxThread
(
    void* context   ///< See parameter documentation above.
)
{
    le_sms_ConnectService();
    bool pdu_type = *((bool *) context);

    int i;
    le_sms_MsgRef_t myMsg;

    for (i = NB_SMS_ASYNC_TO_SEND; i > 0; i--)
    {
        if (pdu_type)
        {
            myMsg = le_sms_SendPdu(PDU_TEST_PATTERN_7BITS,
                            sizeof(PDU_TEST_PATTERN_7BITS)/sizeof(PDU_TEST_PATTERN_7BITS[0]),
                            CallbackTestHandler, (void*) 1);
        }
        else
        {
            myMsg = le_sms_SendText(DEST_TEST_PATTERN, TEXT_TEST_PATTERN,
                            CallbackTestHandler, NULL);
        }
        LE_INFO("-TEST- Create Async text Msg %p", myMsg);

        myMsg = le_sms_Create();

        if (pdu_type)
        {
            le_sms_SetPDU(myMsg, PDU_TEST_PATTERN_7BITS,
                            sizeof(PDU_TEST_PATTERN_7BITS)/sizeof(PDU_TEST_PATTERN_7BITS[0]));
            le_sms_SendAsync(myMsg, CallbackTestHandler,  (void*) 1);
        }
        else
        {
            le_sms_SetDestination(myMsg, DEST_TEST_PATTERN);
            le_sms_SetText(myMsg, TEXT_TEST_PATTERN);
            le_sms_SendAsync(myMsg, CallbackTestHandler, NULL);
        }

        LE_INFO("-TEST- Create Async text Msg %p", myMsg);
    }

    le_event_RunLoop();
    return NULL;
}
コード例 #19
0
ファイル: main.c プロジェクト: H-H-bin/legato-af
//--------------------------------------------------------------------------------------------------
static void* AppHandler
(
    void* ctxPtr
)
{
    AppContext_t * appCtxPtr = (AppContext_t*) ctxPtr;

    LE_INFO("App id: %d", appCtxPtr->appId);

    // Subscribe to eCall state handler
    LE_ASSERT((appCtxPtr->ecallHandler = le_ecall_AddStateChangeHandler(MyECallEventHandler,
                                                                        ctxPtr)) != NULL);

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

    le_event_RunLoop();
}
コード例 #20
0
ファイル: main.c プロジェクト: tegoo/legato-af
//--------------------------------------------------------------------------------------------------
static void* AppHandler
(
    void* ctxPtr
)
{
    AppContext_t * appCtxPtr = (AppContext_t*) ctxPtr;

    LE_DEBUG("App id: %d", appCtxPtr->appId);

    // Subscribe to SIM state handler
    appCtxPtr->statHandler = le_sim_AddNewStateHandler(SimStateHandler, ctxPtr);
    LE_ASSERT(appCtxPtr->statHandler != NULL);

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

    le_event_RunLoop();
}
コード例 #21
0
ファイル: MutexFlux.c プロジェクト: mbaglin/legato-af
// A thread function that attempts to lock all the mutexes in the mutex array passed in as context.
static void* LockMutex
(
    void* context
)
{
    MutexRefArray_t* mra = (MutexRefArray_t*)context;

    int i;
    for (i = 0; i < mra->size; i++)
    {
        le_mutex_Lock(mra->mutexRefArray[i]);
    }

    le_sem_Post(SemaRef);

    le_event_RunLoop();
    return NULL;
}
コード例 #22
0
ファイル: main.c プロジェクト: tegoo/legato-af
//--------------------------------------------------------------------------------------------------
void* ThreadTestHandler( void* ctxPtr )
{

    int i;

    for (i=0; i < NB_PROFILE; i++)
    {
        SessionStateHandler[i] = le_mdc_AddSessionStateHandler (ProfileRef[i],
                                                                HandlerFunc,
                                                                ProfileRef[i]);

        LE_ASSERT(SessionStateHandler[i] != NULL);
    }

    le_sem_Post(ThreadSemaphore);

    le_event_RunLoop();
}
コード例 #23
0
ファイル: main.c プロジェクト: andreasanna/legato-af
//--------------------------------------------------------------------------------------------------
static void* test(void* context)
{
    // Init the test case / test suite data structures
    CU_TestInfo simtestInteractive[] =
    {
        { "Test Interactive le_sim_Authentication()", TestInteractivele_sim_Authentication },
        { "Test le_sim_Create()",                     Testle_sim_Create },
        { "Test le_sim_States()",                     Testle_sim_States },
        CU_TEST_INFO_NULL,
    };


    CU_SuiteInfo suites[] =
    {
        { "SIM tests Interactive",    NULL, NULL, simtestInteractive },
        CU_SUITE_INFO_NULL,
    };

    // Initialize the CUnit test registry and register the test suite
    if (CUE_SUCCESS != CU_initialize_registry())
        exit(CU_get_error());

    if ( CUE_SUCCESS != CU_register_suites(suites))
    {
        CU_cleanup_registry();
        exit(CU_get_error());
    }

    CU_basic_set_mode(CU_BRM_VERBOSE);
    CU_basic_run_tests();

    // Output summary of failures, if there were any
    if ( CU_get_number_of_failures() > 0 )
    {
        fprintf(stdout,"\n [START]List of Failure :\n");
        CU_basic_show_failures(CU_get_failure_list());
        fprintf(stdout,"\n [STOP]List of Failure\n");
    }

    le_event_RunLoop();
}
コード例 #24
0
ファイル: simTest.c プロジェクト: legatoproject/legato-af
//--------------------------------------------------------------------------------------------------
static void* SimPowerCycleIndThread
(
    void* context   ///< Context
)
{
    le_sim_ConnectService();

    SimPowerCycleHdlrRef = le_sim_AddNewStateHandler(TestSimStateHandler, NULL);

    LE_ASSERT(SimPowerCycleHdlrRef);

    //First sem post and  the "simPowerCycleStarted" flag indicate this thread is running
    le_sem_Post(SimPowerCycleSemaphore);
    SimPowerCycleStarted = true;

    LE_INFO("SimPowerCycleIndThread started ...");

    le_event_RunLoop();

    return NULL;
}
コード例 #25
0
ファイル: main.c プロジェクト: H-H-bin/legato-af
//--------------------------------------------------------------------------------------------------
static void* AppHandler
(
    void* ctxPtr
)
{
    AppContext_t * appCtxPtr = (AppContext_t*) ctxPtr;

    LE_DEBUG("App id: %d", appCtxPtr->appId);

    // Subscribe to temperature event handler
    appCtxPtr->eventHandler = le_temp_AddThresholdEventHandler(NULL, &ExpectedStatus);
    LE_ASSERT(appCtxPtr->eventHandler == NULL);

    appCtxPtr->eventHandler=le_temp_AddThresholdEventHandler(ThresholdEventHandler,&ExpectedStatus);
    LE_ASSERT(appCtxPtr->eventHandler != NULL);

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

    le_event_RunLoop();
}
コード例 #26
0
ファイル: multiClientMain.c プロジェクト: H-H-bin/legato-af
void* NewThread
(
    void* contextPtr
)
{
    // Init IPC for the new thread
    ConnectService();

    banner("New Thread Started");

    // Wait a few seconds so that the output of the two tests does not overlap.  It makes it
    // much easier to verify the results.  Yes, this could be done with timers, but no harm
    // just using sleep() here, since this is not the main thread.
    sleep(10);

    // Start the test once the Event Loop is running.
    le_event_QueueFunction(StartTestNewThread, NULL, NULL);

    le_event_RunLoop();
    return NULL;
}
コード例 #27
0
ファイル: MutexFlux.c プロジェクト: mbaglin/legato-af
// A thread "main" function which creates a series of mutexes.
static void* ThreadCreateMutex
(
    void* context
)
{
    long mutexCount = (long)context;
    char mutexNameBuffer[MAX_NAME_BYTES] = {0};

    MutexRefArray_t mra;
    mra.size = mutexCount;
    mra.mutexRefArray = malloc(mutexCount * sizeof(le_mutex_Ref_t));

    LE_INFO("Thread [%s] has started. Creating %ld mutexes.", le_thread_GetMyName(), mutexCount);

    le_mutex_Lock(MutexIndexMutexRef);
    long cnt = 0;
    while (cnt < mutexCount)
    {
        snprintf(mutexNameBuffer, MAX_NAME_BYTES, "[%s]Mutex%ld",
                 le_thread_GetMyName(), MutexCreateIdx);

        mra.mutexRefArray[cnt] = le_mutex_CreateNonRecursive(mutexNameBuffer);
        le_mutex_Lock(mra.mutexRefArray[cnt]);

        MutexCreateIdx++;
        cnt++;
    }
    le_mutex_Unlock(MutexIndexMutexRef);

    // Save the list of mutex refs in the thread's local storage.
    (void) pthread_setspecific(TsdMutexRefKey, &mra);

    le_sem_Post(SemaRef);

    le_event_RunLoop();
    return NULL;
}
コード例 #28
0
ファイル: main.c プロジェクト: H-H-bin/legato-af
//--------------------------------------------------------------------------------------------------
static void* UnitTestInit
(
    void* ctxPtr
)
{
    // pa simu init
    mcc_simu_Init();
    ecall_simu_Init();

    // Set ConfigTree settings for eCall
    le_cfg_IteratorRef_t eCallTestIteratorRef = (le_cfg_IteratorRef_t)0x000ECA11;
    le_cfgSimu_SetStringNodeValue(eCallTestIteratorRef, CFG_NODE_SYSTEM_STD, "ERA-GLONASS");
    le_cfgSimu_SetStringNodeValue(eCallTestIteratorRef, CFG_NODE_VIN, "WM9VDSVDSYA123456");
    le_cfgSimu_SetStringNodeValue(eCallTestIteratorRef, CFG_NODE_VEH, "Commercial-N1");
    le_cfgSimu_SetStringNodeValue(eCallTestIteratorRef, CFG_NODE_PROP, "Diesel");

    // init the services
    le_mcc_Init();
    le_ecall_Init();

    le_sem_Post(InitSemaphore);

    le_event_RunLoop();
}
コード例 #29
0
ファイル: le_smsTest.c プロジェクト: schtipoun/legato-af
static void* MyTxThreadTimeout
(
    void* context   ///< See parameter documentation above.
)
{
    le_sms_ConnectService();
    bool pdu_type = *((bool *) context);

    le_result_t res = LE_FAULT;

    if (pdu_type)
    {
        res = LeSmsSendPduTime(PDU_TEST_PATTERN_7BITS,
                        sizeof(PDU_TEST_PATTERN_7BITS)/sizeof(PDU_TEST_PATTERN_7BITS[0]),
                        CallbackTestHandlerTimeout, (void*) 1, 0);
        if (res == LE_OK)
        {
            LE_ERROR("Test 1/4 FAILED");
            return NULL;
        }
        LE_INFO("Test 1/4 PASSED");

        res = LeSmsSendPduTime(PDU_TEST_PATTERN_7BITS,
                        sizeof(PDU_TEST_PATTERN_7BITS)/sizeof(PDU_TEST_PATTERN_7BITS[0]),
                        CallbackTestHandlerTimeout, (void*) 1, 1);
        if (res != LE_OK)
        {
            LE_ERROR("Test 2/4 FAILED");
            return NULL;
        }
        LE_INFO("Test 2/4 STARTED");


        res = LeSmsSendPduTime(PDU_TEST_PATTERN_7BITS,
                        sizeof(PDU_TEST_PATTERN_7BITS)/sizeof(PDU_TEST_PATTERN_7BITS[0]),
                        CallbackTestHandlerTimeout, (void*) 1, 20);
        if (res == LE_OK)
        {
            LE_ERROR("Test 3/4 FAILED");
            return NULL;
        }
        LE_INFO("Test 3/4 STARTED");

        res = LeSmsSendPduTime(PDU_TEST_PATTERN_7BITS,
                        sizeof(PDU_TEST_PATTERN_7BITS)/sizeof(PDU_TEST_PATTERN_7BITS[0]),
                        CallbackTestHandlerTimeout, (void*) 1, 1);
        if (res != LE_OK)
        {
            LE_ERROR("Test 4/4 FAILED");
            return NULL;
        }
        LE_INFO("Test 4/4 STARTED");
    }
    else
    {
        res = LeSmsSendtextTime(DEST_TEST_PATTERN, TEXT_TEST_PATTERN,
                        CallbackTestHandlerTimeout, NULL, 0);
        if (res == LE_OK)
        {
            LE_ERROR("Test 1/4 FAILED");
            return NULL;
        }
        LE_INFO("Test 1/4 PASSED");

        res = LeSmsSendtextTime(DEST_TEST_PATTERN, TEXT_TEST_PATTERN,
                        CallbackTestHandlerTimeout, NULL, 1);
        if (res != LE_OK)
        {
            LE_ERROR("Test 2/4 FAILED");
            return NULL;
        }
        LE_INFO("Test 2/4 STARTED");

        res = LeSmsSendtextTime(DEST_TEST_PATTERN, TEXT_TEST_PATTERN,
                        CallbackTestHandlerTimeout, NULL, 20 );
        if (res != LE_OK)
        {
            LE_ERROR("Test 3/4 FAILED");
            return NULL;
        }
        LE_INFO("Test 3/4 STARTED");

        res = LeSmsSendtextTime(DEST_TEST_PATTERN, TEXT_TEST_PATTERN,
                        CallbackTestHandlerTimeout, NULL, 1 );
        if (res != LE_OK)
        {
            LE_ERROR("Test 4/4 FAILED");
            return NULL;
        }
        LE_INFO("Test 4/3 STARTED");
    }

    le_event_RunLoop();
    return NULL;
}