This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

osi_start() and multiple tasks

Other Parts Discussed in Thread: CC3200

Hi all,

I'm building a little home project with my CC3200 and am in need of assistance.  I am new to TI products but have a good background with embedded and small board computers.  Here's the big picture.

a.)  I have a sensor which gets read by an ADC

and

b.)  I am wanting to host a webpage 

Right now I have part (a) complete and working as needed.  I am confused on what I need to do to complete part b.

To achieve what I have done so far I did the following : 

Created a new project and added the code from example getting_started_with_ wlan_station and removed the pinging exercise it does to confirm connect.  I then took the ADC reading functionality of the adc example and turned it into a function that I can call from my main().  When I debug my program, it does as expected - connects to my AP, but when I type in it's local IP address on my home network in the browser, I get the SimpleLink Status webpage.  

1. Does the getting_started_with_wlan_station example include an httpserver?

1a. If so, how would I be able to use my own webpage that displays a variable of importance within my program in real time?  This webserver will strictly live locally so it will not be setup for port forwarding etc.  

2.  What exactly does osi_start() do?  After invoking osi_TaskCreate with my ADC function and debugging it, it only executes it once.  Or is the processor actually executing my code and I just can't see it?  

To explain this more, I have posted some code to help make this question more clear.

void main(void) {

//celsiusTemp = 0.0;
float fahreinheitTemp;

fahreinheitTemp = 0.0; //compilier complains
long lRetVal = -1;

BoardInit();
PinMuxConfig();
InitTerm();

//fahreinheitTemp = readADC();

//
// Configure all 3 LEDs
//
GPIO_IF_LedConfigure(LED1|LED2|LED3);

// switch off all LEDs
GPIO_IF_LedOff(MCU_ALL_LED_IND);

//
// Start the SimpleLink Host
//
lRetVal = VStartSimpleLinkSpawnTask(SPAWN_TASK_PRIORITY);
if(lRetVal < 0)
{
ERR_PRINT(lRetVal);
LOOP_FOREVER();
}

//
// Start the WlanStationMode task
//
lRetVal = osi_TaskCreate( WlanStationMode, \
(const signed char*)"Wlan Station Task", \
OSI_STACK_SIZE, NULL, 1, NULL );
if(lRetVal < 0)
{
ERR_PRINT(lRetVal);
LOOP_FOREVER();
}

//Start the ADC task
lRetVal = osi_TaskCreate( readADC, \
(const signed char*)"Read ADC Task", \
OSI_STACK_SIZE, NULL, 1, NULL );
if(lRetVal < 0)
{
 ERR_PRINT(lRetVal);
 LOOP_FOREVER();
}

//
// Start the task scheduler
//
osi_start();
}

I took the same approach as the examples when creating a task and I want my readADC function to be a task that gets executed periodically.  I am going to assume the osi_* class is the TI-RTOS?  

If anyone has any knowledge or documentation that could help me achieve my goal I would greatly appreciate it

Thanks all,

JT

  • Hi Jon,

    Please find inline comments below.

    Jon Torrey said:

    Created a new project and added the code from example getting_started_with_ wlan_station and removed the pinging exercise it does to confirm connect.  I then took the ADC reading functionality of the adc example and turned it into a function that I can call from my main().  When I debug my program, it does as expected - connects to my AP, but when I type in it's local IP address on my home network in the browser, I get the SimpleLink Status webpage.  

    1. Does the getting_started_with_wlan_station example include an httpserver?

    >>>>> By default httpserver is running in NWP. If you dont want to use inbuilt httpserver you can stop it by calling call sl_NetAppStop(). 

    Jon Torrey said:

    1a. If so, how would I be able to use my own webpage that displays a variable of importance within my program in real time?  This webserver will strictly live locally so it will not be setup for port forwarding etc.  

    >>>>>> You can update real time data using POST token. You can designed your own webpage or can modify the existing webpages as per your need. Please refer httpserver application. For more details to use internal http server please refer "www.ti.com/.../swru368.pdf"  and for example code refer "docs\example\CC32xx HTTP Server.pdf".

    In sdk http server code (netapps/http/server) is available if you don't want to use internal http server. Please refer "examples\camera_application" or "example\websock_camera" example code.

    Jon Torrey said:

    2.  What exactly does osi_start() do?  After invoking osi_TaskCreate with my ADC function and debugging it, it only executes it once.  Or is the processor actually executing my code and I just can't see it?  

    >>>> It invoke the scheduler (in case of free rtos ) or kernel (in case of ti rtos) to run. 

    Jon Torrey said:

    I took the same approach as the examples when creating a task and I want my readADC function to be a task that gets executed periodically.  I am going to assume the osi_* class is the TI-RTOS?  

    osi_* calls are wrapper layer for OS. 

    Regards,
    Aashish
  • Hi Aashish,

    Thank you for the information, it really helped.  Shortly after asking this question I did in fact get my own webpage up and running on the CC3200.

    I had a few more questions if you don't mind :

    Aashish Bhanawat said:
    By default httpserver is running in NWP. If you dont want to use inbuilt httpserver you can stop it by calling call sl_NetAppStop(). 

    What is NWP?

    Aashish Bhanawat said:
    Jon Torrey

    2.  What exactly does osi_start() do?  After invoking osi_TaskCreate with my ADC function and debugging it, it only executes it once.  Or is the processor actually executing my code and I just can't see it?  

    >>>> It invoke the scheduler (in case of free rtos ) or kernel (in case of ti rtos) to run.

    So does this mean the OS will take care of executing the task periodically on it's own?  I want to be reading the ADC and updating the webpage all at the same time.  What do I need to do to achieve this?  Will adding my readADC() function as a task do this?  I am eager to try this when I get home.

    Thanks for your help,

    JT

  • Hi Jon,

    [/quote

    Jon Torrey said:

    What is NWP?

    NWP means network processor where all low level networking is done.

    [/quote

    Jon Torrey said:

    So does this mean the OS will take care of executing the task periodically on it's own?  I want to be reading the ADC and updating the webpage all at the same time.  What do I need to do to achieve this?  Will adding my readADC() function as a task do this?  I am eager to try this when I get home.

    Yes OS will take care of this. But, If you are reading ADC and updating it to webpage then I don't think you need to create task as it can be done in single loop in nonos environment.

    eg.

    main()

    {

    initialization()

    connect_to_network()

    while(1)

    {

       readingADC();

       updateToBrowser();

    }

    }

    But, if you have more than 1 independent functionality then you may need to use OS environment to create separate task for each. So, it's entirely depend upon how you design the code/app.

    Regards,

    Aashish