PTP Client and Webserver Initialization Question

This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

  • PTP Client and Webserver Initialization Question

    Hello,

    I am currently evaluating the Embedded Studio Pro Cortex-M ide, libraries and the PTP Client. I have had good success working with the PTP Client by itself. Today I tried adding a Webserver task and was unable to get the Webserver to respond until I moved the PTP Task start code from here:

    C Source Code

    1. IP_Init();
    2. IP_AddLogFilter(IP_MTYPE_APPLICATION);
    3. _IFaceId = IP_INFO_GetNumInterfaces() - 1; // Get the last registered interface ID as this is most likely the interface we want to use in this sample.
    4. OS_SetPriority(OS_GetTaskID(), TASK_PRIO_IP_TASK); // For now, this task has highest prio except IP management tasks.
    5. OS_CREATETASK(&_IPTCB , "IP_Task" , IP_Task , TASK_PRIO_IP_TASK , _IPStack); // Start the TCP/IP_Task.
    6. #if USE_RX_TASK
    7. OS_CREATETASK(&_IPRxTCB , "IP_RxTask" , IP_RxTask , TASK_PRIO_IP_RX_TASK, _IPRxStack); // Start the IP_RxTask, optional.
    8. #endif
    9. OS_CREATETASK(&_PTPcTCB, "PTPClient", _PTPcTask, TASK_PRIO_IP_PTPC , _PTPcStack); // Start the PTP client.
    10. IP_AddStateChangeHook(&_StateChangeHook, _OnStateChange); // Register hook to be notified on disconnects.
    11. IP_Connect(_IFaceId); // Connect the interface if necessary.
    12. OS_SetPriority(OS_GetTaskID(), 255); // Now this task has highest prio for real-time application. This is only allowed when this task does not use blocking IP API after this point.
    13. while (IP_IFaceIsReadyEx(_IFaceId) == 0) {
    14. OS_Delay(50);
    15. BSP_ToggleLED(1);
    16. }
    17. //
    18. // Start Webserver
    19. //
    20. OS_CREATETASK(&_WEBServer_TCB, "Webserver", WebserverTask, TASK_PRIO_WEBS_PARENT, _WEBServer_Stack);
    Display All

    to Here (below). Is this acceptable? Are there any consequences with starting the PTP Client later in the IP/Ethernet setup process?

    C Source Code

    1. IP_Init();
    2. IP_AddLogFilter(IP_MTYPE_APPLICATION);
    3. _IFaceId = IP_INFO_GetNumInterfaces() - 1; // Get the last registered interface ID as this is most likely the interface we want to use in this sample.
    4. OS_SetPriority(OS_GetTaskID(), TASK_PRIO_IP_TASK); // For now, this task has highest prio except IP management tasks.
    5. OS_CREATETASK(&_IPTCB , "IP_Task" , IP_Task , TASK_PRIO_IP_TASK , _IPStack); // Start the TCP/IP_Task.
    6. #if USE_RX_TASK
    7. OS_CREATETASK(&_IPRxTCB , "IP_RxTask" , IP_RxTask , TASK_PRIO_IP_RX_TASK, _IPRxStack); // Start the IP_RxTask, optional.
    8. #endif
    9. IP_AddStateChangeHook(&_StateChangeHook, _OnStateChange); // Register hook to be notified on disconnects.
    10. IP_Connect(_IFaceId); // Connect the interface if necessary.
    11. OS_SetPriority(OS_GetTaskID(), 255); // Now this task has highest prio for real-time application. This is only allowed when this task does not use blocking IP API after this point.
    12. while (IP_IFaceIsReadyEx(_IFaceId) == 0) {
    13. OS_Delay(50);
    14. BSP_ToggleLED(1);
    15. }
    16. OS_CREATETASK(&_PTPcTCB, "PTPClient", _PTPcTask, TASK_PRIO_IP_PTPC , _PTPcStack); // Start the PTP client.
    17. //
    18. // Start Webserver
    19. //
    20. OS_CREATETASK(&_WEBServer_TCB, "Webserver", WebserverTask, TASK_PRIO_WEBS_PARENT, _WEBServer_Stack);
    Display All
  • Hello Jim,

    Sorry about the late reply.

    I assume that your first combination of samples did not work has to do with the following line:

    CodeRunner wrote:

    OS_SetPriority(OS_GetTaskID(), 255);

    This is basically only meant to set the current task to its highest prio possible if there is nothing more to do aka only short checking of the link state
    and maybe LED toggling.

    Without seeing the complete setup I assume you ended up with some kind of prio deadlock in your application setup.

    Basically it should be fine to combine the samples AFTER the link up check. The general rule should always be that
    a client (the end that sends on its own) should only start or be activated if link is up. However we typically have multiple
    checks in samples and or the stack to make sure this should not result in a problem.

    For any server end this is typically not important and you can start it wherever you want. If link is not up no client will
    be able to connect to the server anyhow.

    Best regards,
    Oliver
    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: segger.com/ticket/

    Or you can contact us via e-mail.