<?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>MQX Software SolutionsのトピックRe: Why does MQX crash when using scanf ?</title>
    <link>https://community.nxp.com/t5/MQX-Software-Solutions/Why-does-MQX-crash-when-using-scanf/m-p/640567#M17085</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Adrian:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I put the following code regarding scanf into the hello world demo, and my result is it can work.&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; uint32_t a;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf("Please input : a&amp;nbsp;&amp;nbsp; \r\n");&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; scanf("%d", &amp;amp;a);&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf("a= %d", a);&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tried this with sdk_1.3_FRDM-K64F and classic MQX 4.2,&amp;nbsp; with&amp;nbsp; IAR 7.70.1,&amp;nbsp; and it works as expected.&amp;nbsp; Could you double check it ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Daniel&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 27 Dec 2016 08:43:01 GMT</pubDate>
    <dc:creator>danielchen</dc:creator>
    <dc:date>2016-12-27T08:43:01Z</dc:date>
    <item>
      <title>Why does MQX crash when using scanf ?</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/Why-does-MQX-crash-when-using-scanf/m-p/640566#M17084</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;When running this sample code (KSDK_1.3.0), it crashed when the scanf lines are executed, I was able to get around the first scanf by using %s instead, but I can't find a way to make it work with scanf %d.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Do you know the reason why printf(%s) worked and &lt;SPAN&gt;printf&lt;/SPAN&gt;(%c) didn't ?&lt;/P&gt;&lt;P&gt;And why scanf(%d) didn't also ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When it crashed, I saw in the Task list, unhandled interrupt , unknown error, and the task name is garbage like it was corrupted. When this happened, I no longer can single stepping the code. How do I "trap" the error so it tells me more information ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;void Ui_task(uint32_t initial_data)&lt;BR /&gt;{&lt;BR /&gt; uint32_t numCanTasks, i;&lt;BR /&gt; char c;&lt;BR /&gt; _task_id ids[10] = {0};&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;printf("\n Ui: Hello World \n");&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;while (1) {&lt;BR /&gt; printf("\n&amp;gt;");&lt;BR /&gt; c = fgetc(stdin);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;switch (c) {&lt;BR /&gt; case 'c':&lt;BR /&gt; printf("\nEnter number of CAN Tasks to create: ");&lt;BR /&gt; while (1 != scanf("%d", &amp;amp;numCanTasks)) {&lt;BR /&gt; printf("Invalid input, enter number of CAN tasks to create: ");&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if (numCanTasks&amp;gt;10) {&lt;BR /&gt; numCanTasks=10;&lt;BR /&gt; }&lt;BR /&gt; for (i=0; i&amp;lt;numCanTasks; i++) {&lt;BR /&gt; ids[i] = _task_create(0, CAN_TASK, i );&lt;BR /&gt; printf("\nCreated task 0x%08x", ids[i]);&lt;BR /&gt; }&lt;BR /&gt; break;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;case 'd':&lt;BR /&gt; for (i=0; i&amp;lt;10; i++) {&lt;BR /&gt; if (ids[i]) {&lt;BR /&gt; printf("\nDestroying task 0x%08x", ids[i]);&lt;BR /&gt; _task_destroy(ids[i]);&lt;BR /&gt; ids[i] =0;&lt;BR /&gt; }&lt;BR /&gt; }&lt;BR /&gt; break;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;case 'a':&lt;BR /&gt; for (i=0; i&amp;lt;10; i++) {&lt;BR /&gt; if (ids[i]) {&lt;BR /&gt; printf("\nAborting task 0x%08x", ids[i]);&lt;BR /&gt; _task_abort(ids[i]);&lt;BR /&gt; ids[i] =0;&lt;BR /&gt; }&lt;BR /&gt; }&lt;BR /&gt; break;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;case 'r':&lt;BR /&gt; for (i=0; i&amp;lt;10; i++) {&lt;BR /&gt; if (ids[i]) {&lt;BR /&gt; printf("\nRestarting task 0x%08x", ids[i]);&lt;BR /&gt; _task_restart(ids[i],&amp;amp;i, FALSE);&lt;BR /&gt; }&lt;BR /&gt; }&lt;BR /&gt; break;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;case 'h':&lt;BR /&gt; printf("\nc- create can tasks");&lt;BR /&gt;// printf("\na- abort can tasks");&lt;BR /&gt; printf("\nd- destroy can tasks");&lt;BR /&gt;// printf("\nr- restart can tasks");&lt;BR /&gt; printf("\nh- help");&lt;BR /&gt; break;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;default:&lt;BR /&gt; printf("Invalid selection!\n");&lt;BR /&gt; break;&lt;/P&gt;&lt;P&gt;}&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;_task_block();&lt;BR /&gt;}&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 25 Dec 2016 19:51:28 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/Why-does-MQX-crash-when-using-scanf/m-p/640566#M17084</guid>
      <dc:creator>danny30</dc:creator>
      <dc:date>2016-12-25T19:51:28Z</dc:date>
    </item>
    <item>
      <title>Re: Why does MQX crash when using scanf ?</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/Why-does-MQX-crash-when-using-scanf/m-p/640567#M17085</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Adrian:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I put the following code regarding scanf into the hello world demo, and my result is it can work.&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; uint32_t a;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf("Please input : a&amp;nbsp;&amp;nbsp; \r\n");&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; scanf("%d", &amp;amp;a);&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf("a= %d", a);&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tried this with sdk_1.3_FRDM-K64F and classic MQX 4.2,&amp;nbsp; with&amp;nbsp; IAR 7.70.1,&amp;nbsp; and it works as expected.&amp;nbsp; Could you double check it ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Daniel&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 Dec 2016 08:43:01 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/Why-does-MQX-crash-when-using-scanf/m-p/640567#M17085</guid>
      <dc:creator>danielchen</dc:creator>
      <dc:date>2016-12-27T08:43:01Z</dc:date>
    </item>
  </channel>
</rss>

