<?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>Kinetis MicrocontrollersのトピックRe: Sending Float value through socket</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Sending-Float-value-through-socket/m-p/465332#M28022</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;This is my idea that you have to convert the structure to an char array, then transfer the char array into structure again.&lt;/P&gt;&lt;P&gt;Can you accept the following solution?&lt;/P&gt;&lt;P&gt;typedef struct&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;unsigned int intVar0,&lt;/P&gt;&lt;P&gt;float f1;&lt;/P&gt;&lt;P&gt;}intFloatSVar;&lt;/P&gt;&lt;P&gt;struct intFloatSVar p1;&lt;/P&gt;&lt;P&gt;char array[100];&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;p1.intVar0=10;&lt;/P&gt;&lt;P&gt;p1.f1=1.23;&lt;/P&gt;&lt;P&gt;memcpy(array,&amp;amp;p1,sizeof(intFloatSVar));&lt;/P&gt;&lt;P&gt;sendto(socket, array,sizeof(intFloatSVa),...);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;On the receiver side,&lt;/P&gt;&lt;P&gt;recvfrom(socket,temp,sizeof(intFloatSVar),...);&lt;/P&gt;&lt;P&gt;memcpy(&amp;amp;p1,temp,sizeof(intFloatSVar));&lt;/P&gt;&lt;P&gt;you can recover the structure.&lt;/P&gt;&lt;P&gt;maybe the other people have good idea.&lt;/P&gt;&lt;P&gt;Hope it can help you.&lt;/P&gt;&lt;P&gt;BR&lt;/P&gt;&lt;P&gt;Xiangjun Rong&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 14 Mar 2016 06:50:45 GMT</pubDate>
    <dc:creator>xiangjun_rong</dc:creator>
    <dc:date>2016-03-14T06:50:45Z</dc:date>
    <item>
      <title>Sending Float value through socket</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Sending-Float-value-through-socket/m-p/465329#M28019</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I'm trying to send a structured data from my Source system to Target system through UDP protocol. Structured data contains some int and some float values. I am able to receive int value properly but I am receiving float values as 0 (instead of -0.323114). Source and Target system details are as below :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Source System :&lt;/P&gt;&lt;P&gt;Controller : MK61FX512VMJ12&lt;/P&gt;&lt;P&gt;Protocol&amp;nbsp;&amp;nbsp; : UDP&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Target System :&lt;/P&gt;&lt;P&gt;Processor : VMPC7 (Power PC 750GX ) from Kontron&lt;/P&gt;&lt;P&gt;Operating System : Lynx OS 4.0&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please help.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Mar 2016 05:06:17 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Sending-Float-value-through-socket/m-p/465329#M28019</guid>
      <dc:creator>prashantdev</dc:creator>
      <dc:date>2016-03-10T05:06:17Z</dc:date>
    </item>
    <item>
      <title>Re: Sending Float value through socket</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Sending-Float-value-through-socket/m-p/465330#M28020</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can you use sprintf() to format the structure and copy each variable to the string S, then transfer the string s.&lt;/P&gt;&lt;P&gt;for example :&lt;/P&gt;&lt;P&gt;char str[];&lt;/P&gt;&lt;P&gt;sprinf(&amp;amp;str[0],"%d,%d,%f\n",intVar0,IntVar1,float f);&lt;/P&gt;&lt;P&gt;then transfer the char array str[] with udp protocol.&lt;/P&gt;&lt;P&gt;Another option,I think you can define another structure with the structure like:&lt;/P&gt;&lt;P&gt;typedef struct&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;unsigned int intVar0,&lt;/P&gt;&lt;P&gt;unsugned int intVar1,&lt;/P&gt;&lt;P&gt;char floatVar[]&lt;/P&gt;&lt;P&gt;}intFloatSVar;&lt;/P&gt;&lt;P&gt;struct intFloatSVar;&lt;/P&gt;&lt;P&gt;sprintf(&amp;amp;intFloatSVar.floatVar1[0],"%f\n", float variable);&lt;/P&gt;&lt;P&gt;This is a workaround, hope it can help you.&lt;/P&gt;&lt;P&gt;BR&lt;/P&gt;&lt;P&gt;XiangJun Rong&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 Mar 2016 02:45:48 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Sending-Float-value-through-socket/m-p/465330#M28020</guid>
      <dc:creator>xiangjun_rong</dc:creator>
      <dc:date>2016-03-14T02:45:48Z</dc:date>
    </item>
    <item>
      <title>Re: Sending Float value through socket</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Sending-Float-value-through-socket/m-p/465331#M28021</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN&gt;@ &lt;/SPAN&gt;&lt;SPAN style="color: #51626f; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;XiangJun Rong&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;Hi,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;Thank&amp;nbsp; u for the quick reply.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;But I for some reason I have to send float value without conversion to any other format (not even int ). Plz suggest if it can be done this way.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 Mar 2016 04:03:35 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Sending-Float-value-through-socket/m-p/465331#M28021</guid>
      <dc:creator>prashantdev</dc:creator>
      <dc:date>2016-03-14T04:03:35Z</dc:date>
    </item>
    <item>
      <title>Re: Sending Float value through socket</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Sending-Float-value-through-socket/m-p/465332#M28022</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;This is my idea that you have to convert the structure to an char array, then transfer the char array into structure again.&lt;/P&gt;&lt;P&gt;Can you accept the following solution?&lt;/P&gt;&lt;P&gt;typedef struct&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;unsigned int intVar0,&lt;/P&gt;&lt;P&gt;float f1;&lt;/P&gt;&lt;P&gt;}intFloatSVar;&lt;/P&gt;&lt;P&gt;struct intFloatSVar p1;&lt;/P&gt;&lt;P&gt;char array[100];&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;p1.intVar0=10;&lt;/P&gt;&lt;P&gt;p1.f1=1.23;&lt;/P&gt;&lt;P&gt;memcpy(array,&amp;amp;p1,sizeof(intFloatSVar));&lt;/P&gt;&lt;P&gt;sendto(socket, array,sizeof(intFloatSVa),...);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;On the receiver side,&lt;/P&gt;&lt;P&gt;recvfrom(socket,temp,sizeof(intFloatSVar),...);&lt;/P&gt;&lt;P&gt;memcpy(&amp;amp;p1,temp,sizeof(intFloatSVar));&lt;/P&gt;&lt;P&gt;you can recover the structure.&lt;/P&gt;&lt;P&gt;maybe the other people have good idea.&lt;/P&gt;&lt;P&gt;Hope it can help you.&lt;/P&gt;&lt;P&gt;BR&lt;/P&gt;&lt;P&gt;Xiangjun Rong&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 Mar 2016 06:50:45 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Sending-Float-value-through-socket/m-p/465332#M28022</guid>
      <dc:creator>xiangjun_rong</dc:creator>
      <dc:date>2016-03-14T06:50:45Z</dc:date>
    </item>
  </channel>
</rss>

