freemaster-lite-jsonrpc-api
Drives a running FreeMASTER Lite instance over its WebSocket JSON-RPC interface. Use whenever the user wants to connect to FreeMASTER Lite, start or stop target communication, load ELF or TSA symbols,
SKILL.mdskills/freemaster/freemaster-lite-jsonrpc-api/SKILL.md
GitHubFreeMASTER Lite JSON-RPC API
Interacts with a running FreeMASTER Lite instance over its WebSocket JSON-RPC interface. Covers the full state sequence from WebSocket session setup through target communication and variable access.
When to use
- Connecting to a running FreeMASTER Lite service over WebSocket.
- Calling JSON-RPC methods:
GetAppVersion,StartComm,StopComm,IsCommPortOpen,ReadELF,ReadTSA,DefineVariable,GetVariableInfo,ReadVariable,WriteVariable,Exit. - Distinguishing service reachability from target communication state.
- Interpreting JSON-RPC errors and building a basic call sequence.
Do not use this skill to create .fmcfg files (freemaster-lite-configuration-file),
launch or stop the process (freemaster-lite-start-server /
freemaster-lite-stop-server), or build browser PCM clients
(freemaster-lite-web-application).
State Model
Keep these three states distinct:
- Process running —
fmlite.exehas been launched. - Service reachable — WebSocket session opened to the service.
- Target communication active —
StartCommsucceeded andIsCommPortOpenreturnstrue.
A reachable service does not mean the embedded target is connected.
Quick start
1. open a WebSocket session -- connect to the service
2. call GetAppVersion {} -- confirm service alive
3. call StartComm {} -- open target comm port
4. call IsCommPortOpen {} -- must return true
5. call ReadELF {} -- load symbols (or ReadTSA)
6. call DefineVariable {"variable": {...}} -- if not in .fmcfg
7. call GetVariableInfo {"name": "x"} -- verify addr resolved
8. call ReadVariable {"name": "x"} -- read value
9. call WriteVariable {"name": "x", "value": 10.0}
10. call StopComm {} -- release comm port
Session Setup
Open a WebSocket session to the service.
Input: host (default: "localhost"), port (default: 8090)
Output: { "session_id": "ws-session-id" }
Safe to reconnect or switch to a different instance.
Method Reference
All operations call a JSON-RPC method:
Input: method (string), params (dict or {})
Output: full JSON-RPC response; "result" on success, "error" on failure
| Method | params | result |
|---|---|---|
GetAppVersion |
{} |
version string |
StartComm |
{} |
true |
StopComm |
{} |
true |
IsCommPortOpen |
{} |
true / false |
ReadELF |
{} |
true |
ReadTSA |
{} |
true |
DefineVariable |
{"variable": {...}} |
true |
GetVariableInfo |
{"name": "<name>"} |
variable descriptor |
ReadVariable |
{"name": "<name>"} |
current value |
WriteVariable |
{"name": "<name>", "value": <number>} |
true |
Exit |
{} |
true (terminates process) |
DefineVariable — variable object fields
| Field | Type | Required | Description |
|---|---|---|---|
name |
string | yes | Variable name |
addr |
number | string | yes | Address or ELF symbol name |
type |
string | yes | int, uint, float, double, fract, ufract |
size |
number | yes | 1, 2, 4, or 8 |
shift |
number | no | Right-shift for integer types |
mask |
number | no | AND mask after shifting |
q_n |
number | fract/ufract | Fractional bits |
q_m |
number | fract/ufract | Integer bits |
After DefineVariable, call GetVariableInfo to confirm the definition
resolved to a numeric address (not just a symbol name) before reading or
writing.
Error Handling
On failure, the response contains error instead of result:
{ "jsonrpc": "2.0", "id": 3,
"error": { "code": -32602, "message": "Variable not found: g_unknown" } }
Always check for error before using result.
Guardrails
Scope
- This skill calls the FreeMASTER Lite JSON-RPC API only. It does not modify
.fmcfgfiles or embedded firmware.
Destructive actions
WriteVariablemodifies live target memory. Confirm the variable name and value with the user before writing, especially for safety-critical variables.Exitterminates the FreeMASTER Lite process. Usefreemaster-lite-stop-serverfor process lifecycle management.
Secrets
- No credentials involved in JSON-RPC calls.
Refuse-and-escalate
- If
IsCommPortOpenreturnsfalseafterStartComm, stop and diagnose the connection settings before attempting variable access. - If
GetVariableInfoshows no numeric address afterDefineVariable, do not attemptReadVariableorWriteVariable— the symbol was not resolved.
Validation loop
GetAppVersionmust return a non-empty version string after the session opens.IsCommPortOpenmust returntruebefore any variable operation.- After
DefineVariable,GetVariableInfomust show a numericaddrfield. ReadVariableresult must be a number, not an error object.- After
WriteVariable, read back the value withReadVariableto confirm the write was accepted.
Out of scope
.fmcfgfile creation — usefreemaster-lite-configuration-file.- Process launch or shutdown — use
freemaster-lite-start-server/freemaster-lite-stop-server. - Browser-side PCM client — use
freemaster-lite-web-application.
See Also
freemaster-lite-start-server— launch the service before connectingfreemaster-lite-stop-server— terminate the process viaExitfreemaster-lite-web-application— browser-side PCM API for the same operations