cancel
Showing results for 
Search instead for 
Did you mean: 

How to transmit and receive float type variable with TCP LwIP?

EOzde.1
Associate III

Hi,

I am trying to send and receive the float variable between STM32H745 and my PC. I can only transmit and receive strings. Is it even possible to handle any type of data rather than string.

Thank you.

2 REPLIES 2
TDK
Guru

The chip doesn't care how you're interpreting data bytes. Treat the value as raw data and cast it to uint8_t pointer.

float value = 123.4f;

TransmitData((uint8_t *) &value, 4);

Do the reverse on the PC:

float value = 0.0f;

ReceiveData((uint8_t *) &value, 4);

If you feel a post has answered your question, please click "Accept as Solution".

All just a collection of bytes. Data Representation 101

Typically using IEEE-754 data format for float/double variables. Mantissa/Exponent forms.

https://en.wikipedia.org/wiki/IEEE_754

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..