FreeMASTER WriteFloatVariable function issue

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

FreeMASTER WriteFloatVariable function issue

Jump to solution
1,216 Views
Matisse_Boffy
Contributor II

Dear all,

I use Freemaster 3.1 to control a S12ZVL devkit, I created a control page (html, css, js) for this.

In my js script I use functions that are defined in the freemaster-client.js library.

One of them is pcm.WriteFloatVariable = function(addrdata)

When used, the "." is ignored, if I ask for 10.2 to be written, my float var will contain 102.

 

My code is the following : 

FreeMASTER writefloat issue code.PNG

 
Result in the console is : 
FreeMASTER writefloat issue.PNG
 
My var is defined as a float in FreeMASTER :
FreeMASTER writefloat issue var def.PNG
 
Any clues ? 
 
Regards,
Matisse
0 Kudos
1 Solution
1,210 Views
MichalH
NXP Apps Support
NXP Apps Support

Dear Matisse,

it seems as a bug related to inappropriate use of system locale settings and string conversion. I think your Windows system is set to use "comma" as a floating point, and use point as a "thousand separator". Is this correct?

Can you please make few experiments?

  • Write "10.2" as a string value
  • Write "10,2" with comma (as a string)
  • Store 10.2 to a JavaScript variable and use it in the Write call
  • Inspect your Region & Language settings and let me know how is it set

Thanks,
Michal

 

View solution in original post

0 Kudos
4 Replies
1,211 Views
MichalH
NXP Apps Support
NXP Apps Support

Dear Matisse,

it seems as a bug related to inappropriate use of system locale settings and string conversion. I think your Windows system is set to use "comma" as a floating point, and use point as a "thousand separator". Is this correct?

Can you please make few experiments?

  • Write "10.2" as a string value
  • Write "10,2" with comma (as a string)
  • Store 10.2 to a JavaScript variable and use it in the Write call
  • Inspect your Region & Language settings and let me know how is it set

Thanks,
Michal

 

0 Kudos
1,199 Views
Matisse_Boffy
Contributor II

Dear MichalH,

It was indeed a bug related to Region and Language, setting the format to English, or use a coma in the function ( with Dutch format), solves the issue.

Thank you very much for your answer !

0 Kudos
1,194 Views
MichalH
NXP Apps Support
NXP Apps Support

Dear Matisse,

thank you for confirmation. It is actually a bug in FreeMASTER as it should not depend on system settings and should treat the numbers always in a JavaScript-compatible way (with a dot).

As you already tested, the workaround is to set a locale to English. We will fix this issue in the next version.

Thanks,
Michal

1,209 Views
MichalH
NXP Apps Support
NXP Apps Support

One more point FYI: You should be using just WriteVariable call when you have your FreeMASTER variable defined. You variable is set to float type, so the FreeMASTER will know how to handle it.

The WriteFloatVariable should be used when writing to memory directly. This call uses a C symbol name or a direct address as an argument (while WriteVariable uses the FreeMASTER variable name instead).

Regards,
Michal

0 Kudos