Skip to main content
Visitor II
October 6, 2021
Question

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

  • October 6, 2021
  • 2 replies
  • 1106 views

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.

    This topic has been closed for replies.

    2 replies

    Super User
    October 6, 2021

    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);

    Graduate II
    October 6, 2021

    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