<?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>LPC MicrocontrollersのトピックRe: Chip_UART_ReadBlocking in LPCopen 2.10 for LPC17xx is broken</title>
    <link>https://community.nxp.com/t5/LPC-Microcontrollers/Chip-UART-ReadBlocking-in-LPCopen-2-10-for-LPC17xx-is-broken/m-p/992560#M39091</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Luca,&lt;/P&gt;&lt;P&gt;Hope you are doing well.&lt;/P&gt;&lt;P&gt;Thank you for reporting this and providing this information on our community. As you mention the release is 6 years old and there are no plans to update these libraries as they are for older generation microcontrollers who are coming close to the end of their longevity program. Regardless, it is good information to share with the community who are still using these libraries and microcontrollers. Our current drivers used on the SDK for our newer generations have been updated and modified, I believe the section that references to what you are reporting in the new drivers is as 0&amp;lt;numbytes.&lt;/P&gt;&lt;P&gt;Best Regards,&lt;/P&gt;&lt;P&gt;Sabina&lt;/P&gt;&lt;P&gt;-----------------------------------------------------------------------------------------------------------------------&lt;/P&gt;&lt;P&gt;Note: If this post answers your question, please click the Correct Answer button. Thank you!&lt;/P&gt;&lt;P&gt;-----------------------------------------------------------------------------------------------------------------------&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 23 Mar 2020 23:09:37 GMT</pubDate>
    <dc:creator>Sabina_Bruce</dc:creator>
    <dc:date>2020-03-23T23:09:37Z</dc:date>
    <item>
      <title>Chip_UART_ReadBlocking in LPCopen 2.10 for LPC17xx is broken</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Chip-UART-ReadBlocking-in-LPCopen-2-10-for-LPC17xx-is-broken/m-p/992559#M39090</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;STRONG&gt;Be warned&lt;/STRONG&gt; that function &lt;STRONG&gt;Chip_UART_ReadBlocking&lt;/STRONG&gt; in LPCopen version 2.10 for LPC17xx &lt;STRONG&gt;is broken&lt;/STRONG&gt;, for six years now - as it looks to me that doesn't exist a newer release.&lt;/P&gt;&lt;P&gt;The short function is the following:&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: andale mono, monospace;"&gt;int Chip_UART_ReadBlocking(LPC_USART_T *pUART, void *data, int numBytes)&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;int pass, readBytes = 0;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;uint8_t *p8 = (uint8_t *) data;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;while (readBytes &amp;lt; numBytes) {&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;pass = Chip_UART_Read(pUART, p8, numBytes);&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;numBytes -= pass;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;readBytes += pass;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;p8 += pass;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;return readBytes;&lt;BR /&gt;}&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial, helvetica, sans-serif;"&gt;What happens here is that if the data read is coming in more than one read (because remote host is slow, or even because it's fragmented while reading FIFO) the first read can make &lt;SPAN style="font-family: andale mono, monospace;"&gt;readBytes &amp;gt; numBytes&lt;/SPAN&gt; and the loop will end prematurely.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial, helvetica, sans-serif;"&gt;Take as example reading 10 bytes of data in two passes, the first of 6 bytes: next 4 bytes won't be read.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial, helvetica, sans-serif;"&gt;Besides writing a complete alternative, it could save modifying the control loop as follows&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: andale mono, monospace; "&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;while (0 &amp;lt; numBytes) {&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial, helvetica, sans-serif;"&gt;I guess that this blocking function is less likey to be used than &lt;SPAN style="font-family: andale mono, monospace;"&gt;Chip_UART_Read &lt;SPAN style="font-family: arial, helvetica, sans-serif;"&gt;itself, with a good external timeout limit. I discovered it while using it for a quick intervention in a test, that became eventually a long and complex debug session, as I thought the issue was on my side of code.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Mar 2020 11:10:25 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Chip-UART-ReadBlocking-in-LPCopen-2-10-for-LPC17xx-is-broken/m-p/992559#M39090</guid>
      <dc:creator>lmatte</dc:creator>
      <dc:date>2020-03-20T11:10:25Z</dc:date>
    </item>
    <item>
      <title>Re: Chip_UART_ReadBlocking in LPCopen 2.10 for LPC17xx is broken</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Chip-UART-ReadBlocking-in-LPCopen-2-10-for-LPC17xx-is-broken/m-p/992560#M39091</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Luca,&lt;/P&gt;&lt;P&gt;Hope you are doing well.&lt;/P&gt;&lt;P&gt;Thank you for reporting this and providing this information on our community. As you mention the release is 6 years old and there are no plans to update these libraries as they are for older generation microcontrollers who are coming close to the end of their longevity program. Regardless, it is good information to share with the community who are still using these libraries and microcontrollers. Our current drivers used on the SDK for our newer generations have been updated and modified, I believe the section that references to what you are reporting in the new drivers is as 0&amp;lt;numbytes.&lt;/P&gt;&lt;P&gt;Best Regards,&lt;/P&gt;&lt;P&gt;Sabina&lt;/P&gt;&lt;P&gt;-----------------------------------------------------------------------------------------------------------------------&lt;/P&gt;&lt;P&gt;Note: If this post answers your question, please click the Correct Answer button. Thank you!&lt;/P&gt;&lt;P&gt;-----------------------------------------------------------------------------------------------------------------------&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Mar 2020 23:09:37 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Chip-UART-ReadBlocking-in-LPCopen-2-10-for-LPC17xx-is-broken/m-p/992560#M39091</guid>
      <dc:creator>Sabina_Bruce</dc:creator>
      <dc:date>2020-03-23T23:09:37Z</dc:date>
    </item>
  </channel>
</rss>

