title: TI CC2530 - Convert a float to uint8[] for sending and then convert back to float in reception
body: <p>I need to send some float numbers between some Texas Instrument CC2530 nodes.
  This architecture can only send an array of uint8.<br>
  What I already tried to do was to assign to an uint8 pointer the float pointer with a cast.
  Then I send these bytes and when received, they are copied in a uint8 array.
  In the end I create an another float pointer to which set a cast of the previously created array.<br>
  Actually, this trick works on my pc (using unsigned char instead of uint8) but not in the nodes, where the received number is always 0.</p>
  
  <p>This is the part of the code used in the transmission event (there it creates the <code>msa_Data1</code>, that is the packet transmitted, where the number to send is <code>valMed</code>(a global variable)):</p>
  
  <pre><code>void Data_create(){
      uint8 *sends;
      sends = (uint8 *) &amp;valMed;
      uint8 rec_index;
      for(rec_index=0; rec_index &lt; sizeof(float); ++rec_index){
          msa_Data1[rec_index]= sends[rec_index];
      }
  }
  </code></pre>
  
  <p>In the reception section I have:</p>
  
  <pre><code>uint8 receiveds[sizeof(float)];
  uint8 rec_index;
      for(rec_index=0; rec_index &lt; sizeof(float); ++rec_index){
          receiveds[rec_index]= pData-&gt;dataInd.msdu.p[rec_index];
      }
  float *received= (float *)receiveds;
  </code></pre>
  
  <p>The data from the transmission is received by <code>pData-&gt;dataInd.msdu.p[rec_index]</code></p>
  
  <p>The simulation of the transmission I tried on a pc is:</p>
  
  <pre><code>main(){
      float send= -3.14;
      unsigned char *sends;
      sends = (unsigned char *)&amp;send;
      printf("1:%d, 2:%d, 3:%d, 4:%d \nfloat sent:%f \n", sends[0], sends[1], sends[2], sends[3], send);
      unsigned char receiveds[sizeof(float)];
      int rec_index;
      for(rec_index=0; rec_index &lt; sizeof(float); ++rec_index){
          receiveds[rec_index]= sends[rec_index];
      }
      float *received= (float *)receiveds;
      printf("float received:%f\n", *received);
  } 
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>alex@aspire7738G ~/test $ ./test 
  1:195, 2:245, 3:72, 4:192 
  float sent:-3.140000 
  float received:-3.140000
  </code></pre>
  
  <p>In this case I can see the test working well on the pc, but it does not on the nodes. 
  What's wrong?</p>
  
  <p>Thank you in advance for any help!</p>
  
  <p>Alex</p>