freemaster-lite-web-application
Builds browser-based or Node.js applications that talk to FreeMASTER Lite through freemaster-client.js and the PCM API. Use whenever the user wants to create an HTML or JavaScript client, load client
SKILL.mdskills/freemaster/freemaster-lite-web-application/SKILL.md
GitHubFreeMASTER Web Application
Builds browser-based or Node.js applications that talk to a running FreeMASTER
Lite instance through the freemaster-client.js library and its PCM API.
The web app must be served from the FreeMASTER Lite web_root so the browser
can load the client libraries from the same origin.
When to use
- Building an HTML, JavaScript, or Node.js client for FreeMASTER Lite.
- Using
freemaster-client.js,simple-jsonrpc-js.js, or thePCMAPI. - Reading or writing variables from a browser-side application.
- Hosting the app in FreeMASTER Lite
web_root.
Do not use this skill for direct MCP JSON-RPC calls (freemaster-lite-jsonrpc-api),
.fmcfg file creation (freemaster-lite-configuration-file), or launching the
service (freemaster-lite-start-server).
Quick start
<script src="/simple-jsonrpc-js.js"></script>
<script src="/freemaster-client.js"></script>
<script>
var pcm;
window.onload = function() {
pcm = new PCM('127.0.0.1:8090', function() {
pcm.StartComm('RS232;port=COM3;speed=115200')
.then(function() { return pcm.IsBoardDetected(); })
.then(function() { return pcm.ReadVariable('g_speed'); })
.then(function(r) { console.log('speed:', r.data); })
.catch(function(e) { console.error(e); });
});
};
</script>
Both libraries are served automatically at http://localhost:8090/ when
FreeMASTER Lite is running. Files in the configured web_root override the
built-in copies.
Step-by-step Workflow
1. Include libraries
<script type="text/javascript" src="/simple-jsonrpc-js.js"></script>
<script type="text/javascript" src="/freemaster-client.js"></script>
2. Instantiate PCM
pcm = new PCM('127.0.0.1:8090', on_connect);
First argument: host:port (not a full URL). Second argument: callback
invoked when the WebSocket connection to FreeMASTER Lite is established.
3. Check board and load symbols
Inside on_connect, start communication and confirm the board is detected
before reading variables:
function on_connect() {
pcm.StartComm('RS232;port=COM3;speed=115200')
.then(() => pcm.IsBoardDetected())
.then(() => pcm.ReadELF()) // or pcm.ReadTSA()
.then(() => pcm.ReadVariable('g_motorSpeed'))
.then(r => console.log('speed:', r.data))
.catch(e => console.error(e));
}
All PCM methods return a Promise. Actual data is in response.data.
PCM API Summary
| Category | Key methods |
|---|---|
| Communication | StartComm, StopComm, IsCommPortOpen, EnumCommPorts |
| Board | IsBoardDetected, GetDetectedBoardInfo |
| Symbols | ReadELF, ReadTSA, EnumSymbols, GetSymbolInfo |
| Variables | DefineVariable, GetVariableInfo, EnumVariables, ReadVariable, WriteVariable, DeleteVariable |
| Oscilloscope | SetupOscilloscope, GetOscilloscopeData |
| Recorder | SetupRecorder, StartRecorder, StopRecorder, GetRecorderData |
See references/examples.md for periodic polling, async/await, dynamic
variable definition, and Node.js npm usage patterns.
Guardrails
Scope
- This skill covers browser-side and Node.js application code only.
- The web app must reside in or be served from the FreeMASTER Lite
web_root; cross-origin setups require additional server configuration outside this skill.
Destructive actions
WriteVariablemodifies live target memory. Confirm the target variable and value with the user before writing, especially for safety-critical state.
Secrets
- No credentials involved. If SSL is enabled in
.fmcfg, the browser connects overwss://automatically.
Refuse-and-escalate
- If
IsBoardDetectedfails afterStartComm, stop and direct the user to check the.fmcfgconnection settings and target hardware before continuing to variable access.
Validation loop
- Open the app in a browser; confirm no
404errors for the client library scripts. on_connectcallback must fire — if it does not, the PCM WebSocket connection to FreeMASTER Lite failed.IsBoardDetectedmust resolve (not reject) before variable access.ReadVariableresultresponse.datamust be a number, notundefined.- After
WriteVariable, read back the value to confirm the write succeeded.
Out of scope
- Direct MCP JSON-RPC calls — use
freemaster-lite-jsonrpc-api. - Building the FreeMASTER Lite service or
.fmcfg— usefreemaster-lite-start-serverandfreemaster-lite-configuration-file. - Generic web application help unrelated to FreeMASTER Lite.
See Also
references/examples.md— complete HTML page, polling, async/await, Node.js, and mock-API usage patternsfreemaster-lite-start-server— launch FreeMASTER Lite before loading the appfreemaster-lite-configuration-file— configureweb_rootand connectionsfreemaster-lite-jsonrpc-api— low-level MCP JSON-RPC alternativefreemaster-lite-command-line-arguments—--mock_apiand--web_rootflags