AnsweredAssumed Answered

Using USB CDC to send float data

Question asked by bandari.franck on Feb 21, 2014
Latest reply on Mar 4, 2014 by bandari.franck

I'working with USB to send data from my F3 Discovery to the PC. For that i used the CDC class. I managed to send few bytes of data using the routine below:

uint8_t TabInt[6]={80,90,88,99,10,13}; 
uint8_t  *ptr_int=TabInt;  
uint16_t Lentgh_int=sizeof(TabInt);
CDC_Send_DATA(ptr_int, sizeof(Lentgh_int)); 

/*--------- CDC Definition-------------*/
uint32_t CDC_Send_DATA (uint8_t *ptrBuffer, uint8_t Send_length)
  /*if max buffer is Not reached*/
  if(Send_length < VIRTUAL_COM_PORT_DATA_SIZE)
    /*Sent flag*/
    packet_sent = 0;
    /* send  packet to PMA*/
    UserToPMABufferCopy((unsigned char*)ptrBuffer, ENDP1_TXADDR, Send_length);
    SetEPTxCount(ENDP1, Send_length);
    return 0;
  return 1;

As we can see the  data to be sent is declared as u8. It  Tried to do the same for the data but with no success. 
float_t TabKs[2]={1.215,1.245}; 
uint8_t  *ptr_Ks=(uint8_t*)&TabKs; 
uint8_t Lentgh_Ks=sizeof(TabKs);
CDC_Send_DATA(ptr_Ks, Lentgh_Ks); 
Unfortunately that didn't work for me,The problem i think is that my float value is being sent as one byte and i have to reconstitute it correctly but i don'k know how. If you have an idea how can i resolve my issue, i would be grateful.
Thanks in advance.