<?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 How to do non-blocking reads from serial port in MQX Software Solutions</title>
    <link>https://community.nxp.com/t5/MQX-Software-Solutions/How-to-do-non-blocking-reads-from-serial-port/m-p/197300#M4171</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Our application is structured to send a packet of data and wait for a response. Using blocking reads won't work because if data isn't returned for some reason then the task effectively dead-ends at the read command. How can the port be configured such that reads are non-blocking? Is there some source of MQX serial port usage beyond what is in the IO User's Guide?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 08 Jul 2009 21:08:56 GMT</pubDate>
    <dc:creator>getuptime</dc:creator>
    <dc:date>2009-07-08T21:08:56Z</dc:date>
    <item>
      <title>How to do non-blocking reads from serial port</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/How-to-do-non-blocking-reads-from-serial-port/m-p/197300#M4171</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Our application is structured to send a packet of data and wait for a response. Using blocking reads won't work because if data isn't returned for some reason then the task effectively dead-ends at the read command. How can the port be configured such that reads are non-blocking? Is there some source of MQX serial port usage beyond what is in the IO User's Guide?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Jul 2009 21:08:56 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/How-to-do-non-blocking-reads-from-serial-port/m-p/197300#M4171</guid>
      <dc:creator>getuptime</dc:creator>
      <dc:date>2009-07-08T21:08:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to do non-blocking reads from serial port</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/How-to-do-non-blocking-reads-from-serial-port/m-p/197301#M4172</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;use &lt;EM&gt;&lt;STRONG&gt;fstatus()&lt;/STRONG&gt;&lt;/EM&gt; to check serial port status.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;refer to demo.c at Freescale MQX 3.2\demo\telnet_to_serial\demo.c for example.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;the code snip is below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (fstatus( serial_fd )) {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; c = fgetc( serial_fd );&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (c==IO_ERROR)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; break;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; putchar((char)c);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR /&gt;&lt;/EM&gt;&lt;EM&gt;&amp;nbsp;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;Hope this helps&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Jul 2009 00:18:26 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/How-to-do-non-blocking-reads-from-serial-port/m-p/197301#M4172</guid>
      <dc:creator>eGuy</dc:creator>
      <dc:date>2009-07-09T00:18:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to do non-blocking reads from serial port</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/How-to-do-non-blocking-reads-from-serial-port/m-p/197302#M4173</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;We do this to, what you should do is use itty (interrupt based serial).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I do is run an ESP 'expect send pairs' type arrangment. This way you can have a dedicated RX_TASK which pass's messages back via a message queue. I have developed a full set of routines which we can quickly put into anything that requires two way comm's which works well.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The core of what you are asking happens here:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;
inside ESP_Function()...

 //Get start time so we know where we are _time_get(&amp;amp;StartTime);  //DEBUG, Display time. printf("Start Seconds %u MilliSeconds %u \n", StartTime.SECONDS, StartTime.MILLISECONDS);  //Run this until we get a message from the TX routines while(_msgq_peek(ps_User_Comm_ESP-&amp;gt;QID_of_TX_Task) == NULL) {  _time_get(&amp;amp;CurrentTime);   _time_diff(&amp;amp;StartTime, &amp;amp;CurrentTime, &amp;amp;TimeDifference);  if((TimeDifference.SECONDS &amp;gt;= ps_User_Comm_ESP-&amp;gt;tCommandTimeOut.SECONDS) &amp;amp;&amp;amp; (TimeDifference.MILLISECONDS &amp;gt;= ps_User_Comm_ESP-&amp;gt;tCommandTimeOut.MILLISECONDS))  {   //DEBUG printf("Timer Experied in ESP while waiting for message from TX queue\n");   return ESPR_Timeout;  } }  //DEBUG, Display time it took to get message.  printf("Time Taken = %u.%u Seconds \n", TimeDifference.SECONDS, TimeDifference.MILLISECONDS);  //Get the message that we recieved (from above peek) msg_ptr = _msgq_receive(ps_User_Comm_ESP-&amp;gt;QID_of_TX_Task, 0);&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&amp;nbsp;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Obviously this is only the part of the code which allows you to create your little timeout / error / ok messages.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope this gives you some ideas to move forward&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Jul 2009 06:21:15 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/How-to-do-non-blocking-reads-from-serial-port/m-p/197302#M4173</guid>
      <dc:creator>CarlFST60L</dc:creator>
      <dc:date>2009-07-09T06:21:15Z</dc:date>
    </item>
  </channel>
</rss>

