Errors in sending Float from Device Driver

asked Sep 23, 2019 in GUI Development by 15melazza


I am using an example for a smart thermostat and I am having some sort of issue in sending a float from the GUI via the device driver. 

Below is the property that I am defining  and the very simple method to send the value.



This is where I set the Desired Temp property, in another class I just change the value when the NominalTemperature is changed. It is in line 8 of the code snippet section


Below is the debug info from my Device Driver class located in Application class. The data seems to be fine here and is exactly what I need. 



The real issue comes into play when I print the value and just seem to get random junk I have tried a few different things like how I set the Desired Temp value, printing with different percision, or setting a different variable and printing that instead. The only thing that actually somewhat works is if I set my DesiredTemp property as an int32, this gives me the right value of an integer that is printed correctly. 


Here is the header declaration and c function:

void DeviceDriver_SetDesiredTemp( XFloat aValue );
void DeviceDriver_SetDesiredTemp(XFloat aValue )

#ifdef _ApplicationDeviceClass_

  EwPrint( "Set Temp: %0.2f\n", aValue );




If any more information is needed please let me know and thanks for the help!

1 Answer

0 votes
answered Sep 24, 2019 by Manfred Schweyer


thanks for posting this good question. It tooks some time to nail down the reason for the strange float values. At the end, the answer is simple...

I assume that your DeviceDriver.h file does not contain the declaration of the function DeviceDriver_SetDesiredTemp( XFloat aValue ).

Within the native code section of the onset method of the property DesiredTemp, there is also no declaration of the function DeviceDriver_SetDesiredTemp( XFloat aValue ) available - just the function call. The compiler assumes that the parameter aValue is double and not float. The automatic type conversion finally causes the data garbage.

You can simply avoid that problem by explicitly declaring the function within the native code section, e.g.

But the best solution is to add the declaration of DeviceDriver_SetDesiredTemp( XFloat aValue ) into the DeviceDriver.h file and everything should be fine...

Best regards,


commented Sep 28, 2019 by 15melazza
Hello Manfred,

Thank you for the quick response! I just wanted to point out that I did have the declaration in the DeviceDriver.h file while I was still getting the wierd values however once I added the declaration in the native code my problem was solved. Thank you very much!

Best regards,

-Maysara Elazzazi
commented Sep 28, 2019 by Manfred Schweyer
Hello Maysara,

putting the function declaration within the DeviceDriver.h file must work as well - I assume the compiler did not use it.

If you want to investigate that, try to make some typos within the declaration and see if the compiler complains.

The explicit declaration within the inline code works - as you know ;-) - but this is not the standard way to implement APIs.

Best regards and thanks for your answer,


Ask Embedded Wizard

Welcome to the question and answer site for Embedded Wizard users and UI developers.

Ask your question and receive answers from the Embedded Wizard support team or from other members of the community!

Embedded Wizard Website | Privacy Policy | Imprint