Pass variable from FreeMaster lite (fmcfg) to Node-Red

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

Pass variable from FreeMaster lite (fmcfg) to Node-Red

Jump to solution
1,927 Views
PavolStrbak
NXP Employee
NXP Employee

Hello,

 

I would like ask, regarding the passing some variable or status from fmcfg file into the Node-Red. 

I will use more instances of node-red and I need to know inside the Node-Red which port is defined into fmcfg. And maybe in the future I will need pass more information from that file. 

I would like ask, is it somehow possible? 

(I can't use the settings.js because more instances of NR will use the same settings.js)

Thank you very much

0 Kudos
1 Solution
1,876 Views
iulian_stan
NXP Employee
NXP Employee

Hi Pavol,

I hope I understood your use case this time :). You basically need 2 things in NR:

  1. Discover all FM instances
  2. Identify what board is connected to each FM instance

Bonjour is indeed the way to go. I did not try the package you mentioned (I assume it misses some dependencies), but here's how I did my local test:

  1. I used simple "bonjour" package - I installed it with `npm i bojour` inside NR home directory (it's .node-red inside user folder)
  2. I added bonjour to the global context inside `settings.js` (also inside NR home directory)
  3. Defined my own function to query bonjour services using the package from global context (see print screen)

Untitled.png

 

The flow is barely seen, but it consists of 3 simple nodes. Default `inject` and `debug` plus my custom `function` (you see in the browser editor).

Hope it helps.

View solution in original post

6 Replies
1,904 Views
PavolStrbak
NXP Employee
NXP Employee

Hello @iulian_stan 

Thank you for your answer. 

Okay, I understand. 

I have usecase with more boards. And I would like to have just one flows.json and one settings.js. -> It mean one test program. And the problem is, I can't to have specified more boards in the same time for one instance of node-red. So I will have more fmcfg files and there will just changed the port and connection string for FreeMaster (different COM port). When I started it, it is working well, but I can't programaticaly specified which instance is which (inside the Node-Red) because there is just one diference which is: port number. So I would like to somehow pass the information from fmcfg to NR  as an easy way how to find which fmcfg is running. 

Should I have one question regarding the "bonjour" config. into fmcfg? I read the manual, but I don't understand what does it mean > "publish bonjour service"? Should I use it somehow by NR? 

 

Thank you very much

Pavol

0 Kudos
1,896 Views
iulian_stan
NXP Employee
NXP Employee

Hi,

Now I understand better your scenario. To summarize:

  • You have multiple boards
  • Each board has it's own FM Lite instance
  • Then you have a Node-RED instance
  • Inside NR you have multiple flows
  • Each NR flow connects to a corresponding FM instance

It's unavoidable to have each flow configured for it's corresponding FM Lite instance. Port number can be considered sort of a identifier that tells the flow where it should connect to.

Bonjour functionality would allow NR discover FM Lite service instances, but will complicate your flow - you'd need to add package and logic for service discovery. Bonjour service would be visible to all flows and you would still need to somehow tell each flow which service instance it should connect to.
It would help if you had a single NR instance to avoid hardcoding FM Lite info into the flow, but not so much with multiple FM instances. 

0 Kudos
1,889 Views
PavolStrbak
NXP Employee
NXP Employee

Hi Iulian,

Thank you for your help.

The summarize is not exactly true:

  • Each NR flow connects to a corresponding FM instance

In the NR is not specified which FM instance is used. NR does not know about instance of FM. The NR behavior is not specified on the FM instance. And this is the problem I don't know how to get information about FM instance to specify it. 

 

I am trying to install the:"node-red-node-discovery" but I got an error: 

"ERR! C:\GreenVIP_Testing\Testing\Node-red\0.2.0\node_modules\mdns\src\mdns.hpp(32,10): fatal error C1083: Cannot open include file: 'dns_sd.h': No such file or directory"

even the mdns directory is not exit. 

 

For my scenario is important to have multiple FM instances because it allow to execute independent tests on each board without resource booking. It mean -> Each Instance is connected to board specified by connection string info self fmcfg. And I just need to know which board is running to correctly assign the report and board together. And this I am not able to do, because the information is only in port number or connection string which are not accessible from NR. 

Maybe I will try to write board into into the FT232 chip and I will try dynamically read the information for each instance of FM/NR. Maybe its and easiest way   

 

0 Kudos
1,877 Views
iulian_stan
NXP Employee
NXP Employee

Hi Pavol,

I hope I understood your use case this time :). You basically need 2 things in NR:

  1. Discover all FM instances
  2. Identify what board is connected to each FM instance

Bonjour is indeed the way to go. I did not try the package you mentioned (I assume it misses some dependencies), but here's how I did my local test:

  1. I used simple "bonjour" package - I installed it with `npm i bojour` inside NR home directory (it's .node-red inside user folder)
  2. I added bonjour to the global context inside `settings.js` (also inside NR home directory)
  3. Defined my own function to query bonjour services using the package from global context (see print screen)

Untitled.png

 

The flow is barely seen, but it consists of 3 simple nodes. Default `inject` and `debug` plus my custom `function` (you see in the browser editor).

Hope it helps.

1,853 Views
PavolStrbak
NXP Employee
NXP Employee

Hello Iulian!

 

Thank you very much for help. Now I have it worked, and I will able to use it well in my setup. 

Again thank You very much

 

0 Kudos
1,916 Views
iulian_stan
NXP Employee
NXP Employee

Hi @PavolStrbak,

Variables information lives only on FreeMASTER side. It is not passed into Node-RED, so NR is never aware of what variables are defined in Fmstr. When you use a variable name in a NR node it will be passed as a string argument to Fmstr, and Fmstr will try to resolve the that variable name and map it to the corresponding memory location.

From FreeMASTER's perspective NR a simple client that consumes the API. We did not try using multiple NR instances but don't see a reason why it would not work. 

I'm not sure I understood the part of your question related to the port - could you elaborate a bit. But inside each NR instance PCM node should use the same IP address (of the PC Fmstr is running on) + port number (defined in fmcfg)

 

0 Kudos