docs/how-to/operate/prm-write-how-to.md
Readers of this guide are encouraged to read through the documentation for the PrmDb component and the CmdSequencer component. This guide will go over two methods of updating parameters: through a .dat file that PrmDb loads directly, or by generating a command sequence (.seq file) to dispatch a series of commands.
This guide uses the Ref (reference) F´ project as an example.
Contents:
The fprime-prm-write tool allows you to:
The fprime-prm-write tool accepts parameter values in JSON format. This format is human-readable and supports all F´ parameter types including primitives, enums, arrays, and structs.
The JSON should consist of a key-value map of component instance names to an inner key-value map. The inner key-value map should consist of parameter name-to-value map entries. In other words, the JSON file should have a component name → parameter map structure.
Create a JSON file (e.g., params.json) anywhere in your project directory:
Generic Format:
{
"ComponentInstance": {
"parameterName": value,
"anotherParameter": value
},
"AnotherComponent": {
"paramName": value
}
}
params.json:
{
"Ref.recvBuffComp": {
"parameter1": 20,
"parameter2": -5
},
"Ref.sendBuffComp": {
"parameter3": 25,
"parameter4": 99.99
},
"Ref.typeDemo": {
"CHOICE_PRM": "RED",
"CHOICES_PRM": ["ONE", "BLUE"],
"CHOICE_PAIR_PRM": {
"firstChoice": "RED",
"secondChoice": "BLUE"
}
}
}
Component instance names must be fully qualified (e.g., Ref.recvBuffComp).
[!NOTE] Both
.datand.seqmethods support all F´ parameter types including primitives (strings, numbers, booleans, enums), arrays, and structs. The.seqmethod generates command sequences with complex parameter syntax (e.g.,[1, 2, 3]for arrays,{field: value}for structs).
[!TIP] Using the
--defaultsflag: Thefprime-prm-writetool only automatically includes parameters explicitly listed in your JSON file. If you add the--defaultsflag, the tool will include all parameters that have default values defined in the dictionary. This effectively resets all parameters to their defaults, except for those you specify in the JSON file. This flag works for both.datand.seqfile generation.
All steps from this point on either take place in the terminal or the GDS GUI.
.dat FileWith this method, the user uplinks a .dat file to the FSW and sends the PRM_LOAD_FILE and PRM_COMMIT_STAGED commands to the PrmDb component, which loads parameter values in batch from the file.
.dat FileNow you will run the fprime-prm-write tool in the terminal.
General syntax:
fprime-prm-write dat <path/to/paramFile.json> --dictionary <path/to/TopologyDictionary.json>
Example: Ref project:
fprime-prm-write dat params.json
--dictionary build-artifacts/Linux/Ref/dict/RefTopologyDictionary.json
This creates params.dat in the same directory as your JSON file.
[!NOTE] The output file is named based on your input JSON file. If your JSON file is named
my_params.json, the output will bemy_params.dat.
fprime-gds and open up the browser windowparams.dat file.
FileHandling.prmDb.PRM_LOAD_FILEpath/params.datMERGE (merge with existing) or CLEAR (replace all)PrmFileLoadCompleteExpected events:
| Event | Status | Description |
|---|---|---|
PrmFileLoadComplete | ✓ | File loaded successfully |
PrmDbFileLoadFailed | ✗ | File not found |
PrmFileBadCrc | ✗ | CRC checksum error |
After verifying the load succeeded, commit to make parameters active:
In the Commanding tab, send FileHandling.prmDb.PRM_COMMIT_STAGED (no arguments). Check the Events tab for PrmDbCopyAllComplete to confirm the commit succeeded.
Downlink and decode PrmDb.dat
If your deployment has file downlink configured (using Svc.FileDownlink), you can verify by downloading and decoding the parameter database:
Use your deployment's file downlink commands to retrieve PrmDb.dat from the FSW
bash fileDownlink.FileDownlink_SendFile
Decode the downloaded file to a JSON file for human readability
General syntax: Using the inverse fprime-prm-decode tool
fprime-prm-decode PrmDb.dat
--dictionary <path/to/TopologyDictionary.json>
--format json
--output downlinked_params.json
Compare with your input
diff params.json downlinked_params.json
.seq FileWith this method, the user compiles a .seq file into a .bin and uplinks it to CmdSequencer, which dispatches _PRM_SET commands (and _PRM_SAVE if --save was used) to each component.
[!TIP] Using the
--saveflag: The generated.seqfile contains_PRM_SETcommands that update parameter values in memory. If you want the changes to persist across FSW restarts, add the--saveflag to include_PRM_SAVEcommands after each_PRM_SET, which writes the parameters to the PrmDb.dat file on the FSW.
General syntax:
fprime-prm-write seq <json file> --dictionary <path/to/TopologyDictionary.json>
Example: Ref project:
fprime-prm-write seq params.json \
--dictionary build-artifacts/Linux/Ref/dict/RefTopologyDictionary.json
This creates params.seq in the same directory as your JSON file.
Compile the sequence file to binary format:
fprime-seqgen params.seq --dictionary <path/to/TopologyDictionary.json>
This creates params.bin.
Load the sequence into CmdSequencer in the GDS GUI:
params.bin file.
/seq<project>.cmdSeq.CS_RUN command with the binary file name
/seq/params.bin)BLOCK: The command waits for the sequence to complete before returning statusNO_BLOCK: The command returns immediately and the sequence runs in the backgroundVerify the sequence executed successfully by checking events in the Events tab or command line
grep -E "CS_Sequence" <path/to/project/log/file>
| Event | Status | Description |
|---|---|---|
CS_SequenceLoaded | ✓ | Sequence file loaded successfully |
CS_CommandComplete | ✓ | Each command in sequence completed |
CS_SequenceComplete | ✓ | Entire sequence finished successfully |
CS_FileNotFound | ✗ | .bin file not found |
CS_FileReadError | ✗ | Error reading the file |
CS_FileInvalid | ✗ | Invalid file format or structure |
CS_FileCrcFailure | ✗ | CRC checksum mismatch |
CS_CommandError | ✗ | A command in the sequence failed |
For more details, follow the standard F´ sequencing workflow.
PrmFileBadCrcCause: CRC checksum mismatch.
Fix: Regenerate with an up-to-date version of fprime-prm-write.
PrmDbFileLoadFailedCause: File not found.
Fix: Verify file path and ensure it's accessible to the FSW (uplinked to the spacecraft, providing the onboard file path).
RuntimeError: Unable to find param <name> in dictionaryCause: Parameter name doesn't match dictionary.
Fix:
Ref.recvBuffComp)