How Can I use FreeMasterLite to provide remote access for clients to the target microcontroller?
Assuming you have a FreeMASTER Lite application running on your local host (ex: http://127.0.0.1:8090), it can be accessed from an external network using the public IP address of the machine (instead of 127.0.0.1) + port number FreeMASTER Lite is running on (http://public_ip:port_number).
Please note that you need to make sure there are no firewall rules blocking inbound rules to FreeMASTER Lite. Additionally, if the machine is connected to a private network (ex: company network) there may be additional rules, blocking the access from outside, managed by the IT team.
Apologies for a delayed reply,
Iulian
Dear iulian,
I have no experience with freemaster lite. can you please explain in more details what are the steps I should follow with freemasterlite to achieve this. or if there is a link for some explanation video to start using it ,it will be useful.
Thank you in advance.
If you have no prior experience with FreeMASTER tool you can start with our Four Part Webinar Series (the 4th part is focused primarily on FreeMASTER Lite and JSON-RPC API).
Another good resource is the How-To page.
The following pictures shows (on a very high level) what has to be done:
FreeMASTER Lite has a built-in web server that can host the web application that you develop in step 2 (in the above image). When you start FM Lite executable, specify the path to your web app like this:
node.exe --web_root "C:\My_FreeMASTER_Lite_App"
Once it is running, you can open your local web browser and navigate to `localhost:8090` or `127.0.0.1:8090` and check your application. (8090 is the default port number, it can be changed using `--port` argument)
There are no additional steps required to access it from a remote PC. You just need to get the public IP address of the machine FreeMASTER Lite is running on, and open it on the remote PC.
For example:
On the local PC: access https://whatismyipaddress.com/. Let's assume it shows `130.120.110.100`
On the remote PC: open the web browser and navigate to `130.120.110.100:8090`
Should you require more details on any step/aspect, we would be happy to assist you.
thank you very much dear iulian. but I don't understand where I can write the path of my web app? when the FM lite operates it shows this screen
which even has no capability of writing in it . and then immediately open this default page
I think I should make something to show my own web page in the web server and then the remote PC can navigate to my IP to see the same web page I see and then he can control the target board from his remote dashboard isn't that right?
May I only navigate to the path of my web page on the browser which open on the default page ignoring this page ?
By default, FreeMASTER Lite, serves the web content from the 'html' folder that is located inside the installation directory.
You can either:
Dear iulian,
Now, I reached the point where the remote device can see the dashboard (control web page) that I see. the problem now is that he can't control the parameters like me. when he changes the value of any parameter ,nothing occurs. what can I do? is there any setting or configuration that must be adjusted from the FreeMaster itself(where I watch the values of parameters) or what?
I would need some more details:
Yes, I mean embedded application variables. To load symbolic information, I used ELF File and to change these parameters, I used WriteVariable API call.
WriteVariable API call operate on variables defined FreeMASTER Lite configuration file. So you would need to have a structure like the one bellow in your .fmcfg file:
{
...
"variables": [
{
"name": "var16", <-- the variable to be used in ReadVariable/WriteVriable (can be any string)
"addr": "var16", <-- symbol name (should match the variable name defined the embedded project)
"size": 2, <-- variable size in bytes [1,2,4,8]
"type": "uint" <-- variable type [int,uint,float,double]
},
...
]
...
}
Another option, that does not require defining those variables is to use "typed" API calls: WriteIntVariable, WriteUIntVariable, WriteFloatVariable, WriteDoubleVariable. These functions use 3 arguments:
Same approach applies to read functions.
Hope it helps
And then, what should I do with the .fmcfg file ?
You pass it as input parameter to the FreeMASTER Lite executable.
node.exe my_proj.fmcfg
Please refer to Start Guide for more details. It is accessible from the default webpage that opens when you start FreeMASTER Lite, or you can open the following file: "FreeMASTER Lite/html/guide/index.html" in the web browser.
which device must do this step? the server device or the user (remote) device? The web page opened by FreeMasterLite after putting my file in the installation folder of it (on the server(main) device) succeeded in controlling the parameters. the remote device is who can't control them. I referred to the guide but I couldn't find an answer.
The configuration file always stays on the main device, where the service is running. But I got wrong your issue - I thought you were unable to control the parameters on both, local and remote device.
In this case - check whether PCM is initialized with correct address and is able to reach remote server:
pcm = new PCM('main_ip:8090', on_connect, on_close, on_error);
function on_connect() {
console.log('Client connected');
}
function on_close(event) {
console.log('Connection closed');
console.log(event);
}
function on_error(event) {
console.log('Connection error');
console.log(event);
}
Note that PCM should be initialized using main machine address. You can also use window.location.host like this:
pcm = new PCM(window.location.host, on_connect, on_close, on_error);
If you already use main machine address. Check whether there any connection errors.
I am using two pcm objects pcm1 and pcm2 to control two boards. I initialized them with 'localhost 41000' and 'localhost41010'. Have I to change both of them or what?
I did not quite understand your issue, could you elaborate a bit.
May I change this line in my code:
You would need to run 2 instances of FreeMASTRE Lite, but you will need to specify the a different port number for the second instance, because FreeMASTER Lite will not start if default port is being used.
It is done either from command line:
node.exe --port 8091
or via .fmcfg file.
{
port: 8091
...
}
You can set any unused port, 8091 is used as reference.
Then you can replace:
pcm2 = new PCM(rpcs_addr2, on_connected2, on_error, on_error);
with
pcm2 = new PCM(main_ip:8091, on_connected2, on_error, on_error);