FreeMASTER WriteFloatVariable function issue

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

FreeMASTER WriteFloatVariable function issue

跳至解决方案
1,918 次查看
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 项奖励
回复
1 解答
1,912 次查看
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 项奖励
回复
4 回复数
1,913 次查看
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 项奖励
回复
1,901 次查看
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 项奖励
回复
1,896 次查看
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,911 次查看
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 项奖励
回复