Quantcast
Viewing all articles
Browse latest Browse all 262198

CCS/CC3120: Integrating Multiple Threads With Local_ota HTTP Get Example

Part Number:CC3120

Tool/software: Code Composer Studio

Hi,

I'm using the CC3120 to transmit data from the MSP432P4111's ADC to a webpage using a variation on the local_ota example. I'm totally new to integrating a dev board with http, so I'm having some problems implementing my own code and the http routines together.

I've gotten just the base adcbuf.c driver working in this way, where the adcbuf routine runs in the background and the link_local_task can access its data when an HTTP Get request comes in. Now I'm trying to implement my own code that manipulates the adcbuf data. So far I can connect to the Wi-Fi and then either run my adc manipulation code, or the link_local_task that handles HTTP Get requests, but not both at the same time. My code won't run in the background alongside the adcbuf routine.

Any suggestions on how to achieve this? Am I just trying to do too much at once?

I'm including the main part of local_ota.c where I set the priorities for the different threads. My thread starts at the very bottom.

void * mainThread(void *arg)
{
    uint32_t RetVal;
    pthread_attr_t pAttrs;
    pthread_attr_t pAttrs_spawn;
    struct sched_param priParam;
    struct timespec ts = {0};

    Board_initGPIO();
    Board_initSPI();

    /* init Terminal, and print App name */
    InitTerm();
    /* initilize the realtime clock */
    clock_settime(CLOCK_REALTIME, &ts);

    DisplayBanner(APPLICATION_NAME, APPLICATION_VERSION);

    InitializeAppVariables();

    /* Switch off all LEDs on boards */
    GPIO_write(Board_LED0, Board_LED_OFF);
    GPIO_write(Board_LED1, Board_LED_OFF);
    GPIO_write(Board_LED2, Board_LED_OFF);

    /* initializes signals for all tasks */
    sem_init(&LocalOtaTask_ControlBlock.localOtaConnDoneSignal, 0, 0);
    sem_init(&LocalOtaTask_ControlBlock.localOtaConnDoneToOtaServerSignal, 0, 0);
    sem_init(&LinkLocal_ControlBlock.otaReportServerStartSignal, 0, 0);
    sem_init(&LinkLocal_ControlBlock.otaReportServerStopSignal, 0, 0);
    sem_init(&ADC_ControlBlock.httpWait, 0, 0);

    /* create the sl_Task */
    pthread_attr_init(&pAttrs_spawn);
    priParam.sched_priority = SPAWN_TASK_PRIORITY;
    RetVal = pthread_attr_setschedparam(&pAttrs_spawn, &priParam);
    RetVal |= pthread_attr_setstacksize(&pAttrs_spawn, TASK_STACK_SIZE);

    RetVal = pthread_create(&gSpawnThread, &pAttrs_spawn, sl_Task, NULL);

    if(RetVal)
    {
        while(1)
        {
            ;
        }
    }

    pthread_attr_init(&pAttrs);
    priParam.sched_priority = 3;
    RetVal = pthread_attr_setschedparam(&pAttrs, &priParam);
    RetVal |= pthread_attr_setstacksize(&pAttrs, TASK_STACK_SIZE);

    if(RetVal)
    {
        while(1)
        {
            ;        /* error handling */
        }
    }

    RetVal = pthread_create(&gLocalOtaThread, &pAttrs, localOtaTask, NULL);

    if(RetVal)
    {
        while(1)
        {
            ;
        }
    }

    pthread_attr_init(&pAttrs);
    priParam.sched_priority = 1;
    RetVal = pthread_attr_setschedparam(&pAttrs, &priParam);
    RetVal |= pthread_attr_setstacksize(&pAttrs, LINKLOCAL_STACK_SIZE);

    if(RetVal)
    {
        while(1)
        {
            ;        /* error handling */
        }
    }

    RetVal = pthread_create(&gLinklocalThread, &pAttrs, linkLocalTask, NULL);

    if(RetVal)
    {
        while(1)
        {
            ;
        }
    }

    pthread_attr_init(&pAttrs);
    priParam.sched_priority = 5;
    RetVal = pthread_attr_setschedparam(&pAttrs, &priParam);
    RetVal |= pthread_attr_setstacksize(&pAttrs, TASK_STACK_SIZE);

    if(RetVal)
    {
        while(1)
        {
            ;        /* error handling */
        }
    }

    RetVal = pthread_create(&gOtaReportServerThread, &pAttrs, otaReportServerTask,
                       NULL);

    if(RetVal)
    {
        while(1)
        {
            ;
        }
    }

    //This is where the thread for my code is created.
    
    pthread_attr_init(&pAttrs);
    priParam.sched_priority = 2;
    RetVal = pthread_attr_setschedparam(&pAttrs, &priParam);
    RetVal |= pthread_attr_setstacksize(&pAttrs, TASK_STACK_SIZE);

    if(RetVal)
    {
        while(1)
        {
            ;        /* error handling */
        }
    }

    RetVal = pthread_create(&gadcThread, &pAttrs, adcThread, NULL);

    if(RetVal)
    {
        while(1)
        {
            ;
        }
    }

    return(0);
}

Thanks,

-Daniel


Viewing all articles
Browse latest Browse all 262198

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>