<?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のトピックStrange code in lpc175x_6x lib USBCDC demo</title>
    <link>https://community.nxp.com/t5/LPC-Microcontrollers/Strange-code-in-lpc175x-6x-lib-USBCDC-demo/m-p/518677#M2802</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by ivbor on Mon Apr 14 04:39:11 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Folder:\lpc175x_6x\Examples\USBDEV\USBCDC\, file: cdcuser.c&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;lines 72 and 73&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;/*----------------------------------------------------------------------------
&amp;nbsp; read data from CDC_OutBuf
 *---------------------------------------------------------------------------*/
int CDC_RdOutBuf (char *buffer, const int *length) {
&amp;nbsp; int bytesToRead, bytesRead;

&amp;nbsp; /* Read *length bytes, block if *bytes are not available*/
&amp;nbsp; bytesToRead = *length;
&amp;nbsp; bytesToRead = (bytesToRead &amp;lt; (*length)) ? bytesToRead : (*length);
&amp;nbsp; bytesRead = bytesToRead;&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;SPAN&gt;In which case bytesToRead &amp;lt; (*length) will retun true? Is it possible? Thx&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 15 Jun 2016 17:34:06 GMT</pubDate>
    <dc:creator>lpcware</dc:creator>
    <dc:date>2016-06-15T17:34:06Z</dc:date>
    <item>
      <title>Strange code in lpc175x_6x lib USBCDC demo</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Strange-code-in-lpc175x-6x-lib-USBCDC-demo/m-p/518677#M2802</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by ivbor on Mon Apr 14 04:39:11 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Folder:\lpc175x_6x\Examples\USBDEV\USBCDC\, file: cdcuser.c&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;lines 72 and 73&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;/*----------------------------------------------------------------------------
&amp;nbsp; read data from CDC_OutBuf
 *---------------------------------------------------------------------------*/
int CDC_RdOutBuf (char *buffer, const int *length) {
&amp;nbsp; int bytesToRead, bytesRead;

&amp;nbsp; /* Read *length bytes, block if *bytes are not available*/
&amp;nbsp; bytesToRead = *length;
&amp;nbsp; bytesToRead = (bytesToRead &amp;lt; (*length)) ? bytesToRead : (*length);
&amp;nbsp; bytesRead = bytesToRead;&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;SPAN&gt;In which case bytesToRead &amp;lt; (*length) will retun true? Is it possible? Thx&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 17:34:06 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Strange-code-in-lpc175x-6x-lib-USBCDC-demo/m-p/518677#M2802</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T17:34:06Z</dc:date>
    </item>
    <item>
      <title>Re: Strange code in lpc175x_6x lib USBCDC demo</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Strange-code-in-lpc175x-6x-lib-USBCDC-demo/m-p/518678#M2803</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by Pacman on Mon Apr 21 14:37:07 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;That code looks absolutely wonderful. :)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;length is a const int *, which means: it's not marked volatile, thus you can assume that all the *length will always return the same value.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So... Let's say length points to a value of 10.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;bytesToRead = 10.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;bytesToRead = (10 &amp;lt; 10) ? 10 : 10;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;BytesRead = 10;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In other words, the above can be simplified to:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;bytesRead = *length;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;... I've also seen code (somewhere else) like this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;if(a == 10)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;{&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; a = 10;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;...Anyway, the code you've mentioned is clearly not doing what the programmer intended it to do.&lt;/SPAN&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 17:34:07 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Strange-code-in-lpc175x-6x-lib-USBCDC-demo/m-p/518678#M2803</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T17:34:07Z</dc:date>
    </item>
  </channel>
</rss>

