<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Can I start a new task in a CGI callback function? in MQX Software Solutions</title>
    <link>https://community.nxp.com/t5/MQX-Software-Solutions/Can-I-start-a-new-task-in-a-CGI-callback-function/m-p/252660#M7324</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="margin-bottom: .0001pt;"&gt;Hi Daniel, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;For a cgi, application callback functions are define in HTTPD_CGI_LINK_STRUCT.&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;So when requested a cgi web page, the RTCS library calls the cgi_ callback function linked to this web page by the HTTPD_CGI_LINK_STRUCT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;From the cgi callback function, we can request the RTCS to send a header. An example for this in MQX 4.0, in /rtcs/examples/httpsrv/cgi.c, cgi callback functions should look like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;static _mqx_int cgi_rtc_data(HTTPD_SESSION_STRUCT *session) &lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;{&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp; TIME_STRUCT time;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp; int min, hour;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp; _time_get(&amp;amp;time);&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp; min = time.SECONDS / 60;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp; hour = min / 60;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp; min %= 60;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt; session-&amp;gt;response.contenttype = CONTENT_TYPE_PLAIN;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp; httpd_sendhdr(session, 0, 0);&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp; CGI_SEND_NUM(hour);&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp; CGI_SEND_NUM(min);&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp; CGI_SEND_NUM(time.SECONDS % 60);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp; return session-&amp;gt;request.content_len;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;}&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;Regards&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;Sol &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 24 Feb 2014 22:54:32 GMT</pubDate>
    <dc:creator>soledad</dc:creator>
    <dc:date>2014-02-24T22:54:32Z</dc:date>
    <item>
      <title>Can I start a new task in a CGI callback function?</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/Can-I-start-a-new-task-in-a-CGI-callback-function/m-p/252659#M7323</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now I have a http server task, and is it possible to start a task in CGI callback function when I get a http request from the client?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 22 Feb 2014 18:48:43 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/Can-I-start-a-new-task-in-a-CGI-callback-function/m-p/252659#M7323</guid>
      <dc:creator>danielchai</dc:creator>
      <dc:date>2014-02-22T18:48:43Z</dc:date>
    </item>
    <item>
      <title>Re: Can I start a new task in a CGI callback function?</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/Can-I-start-a-new-task-in-a-CGI-callback-function/m-p/252660#M7324</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="margin-bottom: .0001pt;"&gt;Hi Daniel, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;For a cgi, application callback functions are define in HTTPD_CGI_LINK_STRUCT.&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;So when requested a cgi web page, the RTCS library calls the cgi_ callback function linked to this web page by the HTTPD_CGI_LINK_STRUCT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;From the cgi callback function, we can request the RTCS to send a header. An example for this in MQX 4.0, in /rtcs/examples/httpsrv/cgi.c, cgi callback functions should look like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;static _mqx_int cgi_rtc_data(HTTPD_SESSION_STRUCT *session) &lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;{&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp; TIME_STRUCT time;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp; int min, hour;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp; _time_get(&amp;amp;time);&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp; min = time.SECONDS / 60;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp; hour = min / 60;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp; min %= 60;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt; session-&amp;gt;response.contenttype = CONTENT_TYPE_PLAIN;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp; httpd_sendhdr(session, 0, 0);&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp; CGI_SEND_NUM(hour);&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp; CGI_SEND_NUM(min);&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp; CGI_SEND_NUM(time.SECONDS % 60);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp; return session-&amp;gt;request.content_len;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;}&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;Regards&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;Sol &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 24 Feb 2014 22:54:32 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/Can-I-start-a-new-task-in-a-CGI-callback-function/m-p/252660#M7324</guid>
      <dc:creator>soledad</dc:creator>
      <dc:date>2014-02-24T22:54:32Z</dc:date>
    </item>
    <item>
      <title>Re: Can I start a new task in a CGI callback function?</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/Can-I-start-a-new-task-in-a-CGI-callback-function/m-p/252661#M7325</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Sol,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for your reply.&lt;/P&gt;&lt;P&gt;The question is that in this callback function, can I have call function _task_create to start a task?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-Daniel&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Feb 2014 13:16:55 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/Can-I-start-a-new-task-in-a-CGI-callback-function/m-p/252661#M7325</guid>
      <dc:creator>danielchai</dc:creator>
      <dc:date>2014-02-25T13:16:55Z</dc:date>
    </item>
    <item>
      <title>Re: Can I start a new task in a CGI callback function?</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/Can-I-start-a-new-task-in-a-CGI-callback-function/m-p/252662#M7326</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Daniel,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Apologies for a late reply, but I have done this.&amp;nbsp; I just made sure the task I was creating was in my MQX_template_list[] and that is was not MQX_AUTO_START_TASK.&amp;nbsp; You need take care with the priority of the new task so that it doesn't consume the CPU and prevent the CGI callback from returning.&amp;nbsp; In my case, I passed a delay parameter to the new task.&amp;nbsp; The first function call in the new task was _time_delay_ticks(param)..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Paul&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Sep 2014 15:18:19 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/Can-I-start-a-new-task-in-a-CGI-callback-function/m-p/252662#M7326</guid>
      <dc:creator>pbanta</dc:creator>
      <dc:date>2014-09-15T15:18:19Z</dc:date>
    </item>
  </channel>
</rss>

