FreeMASTER WriteFloatVariable function issue

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

FreeMASTER WriteFloatVariable function issue

ソリューションへジャンプ
1,905件の閲覧回数
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,899件の閲覧回数
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,900件の閲覧回数
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,888件の閲覧回数
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,883件の閲覧回数
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,898件の閲覧回数
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 件の賞賛
返信