Command Line Interface (CLI) Usage Guide¶
The command line offers complete and precise control over FMU Manipulation Toolbox, ideal for automation and batch processing.
Available Commands¶
FMU Manipulation Toolbox provides four main commands:
| Command | Usage |
|---|---|
fmutool | FMU analysis and manipulation |
fmucontainer | FMU container creation |
fmusplit | Extract FMUs from a container |
datalog2pcap | Convert CAN datalog CSV to PCAP (experimental) |
fmutool: Main Command¶
Basic Syntax¶
Required Options¶
The FMU to analyze or modify.
Save Options¶
⚠️ Important: Without this option, no modifications are saved!
Analysis Operations¶
Display FMU Summary¶
Output:
FMU Information:
Name: module
FMI Version: 2.0
GUID: {abc-123-def}
Number of variables: 42
Number of parameters: 5
Number of inputs: 10
Number of outputs: 15
Check FMI Compliance¶
Output:
Checking FMU: module.fmu
✓ modelDescription.xml is valid
✓ Schema validation passed
⚠ Warning: Variable 'temp' has no description
✓ All value references are unique
List All Ports in CSV¶
Generated CSV content:
name;newName;valueReference;causality;variability
Motor.Speed;Motor.Speed;0;input;continuous
Motor.Torque;Motor.Torque;1;output;continuous
Controller.Kp;Controller.Kp;2;parameter;fixed
Modification Operations¶
Remove Top-Level Hierarchy¶
Before:
Command:
After:
Merge First Level¶
Before:
Command:
After:
Remove Prefix¶
Before:
Command:
After:
Rename from CSV File¶
Step 1: Create CSV
Step 2: Edit CSV
Edit renaming.csv:
name;newName;valueReference;causality;variability
Motor.Speed;Engine.Velocity;0;input;continuous
Motor.Torque;Engine.Force;1;output;continuous
Step 3: Apply modifications
Tip: Leaving newName empty removes the port!
Filtering Operations¶
Filter by Regular Expression¶
Keep only matching ports:
Remove matching ports:
Regular Expression Examples¶
# Keep everything starting with "Motor."
-keep-only-regexp "^Motor\..*"
# Remove everything containing "debug"
-remove-regexp ".*debug.*"
# Keep ports ending with "Temperature"
-keep-only-regexp ".*Temperature$"
# Remove ports starting with underscore
-remove-regexp "^_.*"
Remove All Ports¶
⚠️ Warning: This removes ALL ports! Use with filters.
Filter by Port Type¶
Operations on Parameters Only¶
List only parameters:
Remove all parameters:
Operations on Inputs Only¶
# List inputs
fmutool -input module.fmu -only-inputs -dump-csv inputs.csv
# Rename inputs
fmutool -input module.fmu -only-inputs -rename-from-csv new_inputs.csv -output module.fmu
Operations on Outputs Only¶
# List outputs
fmutool -input module.fmu -only-outputs -dump-csv outputs.csv
# Filter outputs
fmutool -input module.fmu -only-outputs -keep-only-regexp "^Result\." -output module.fmu
Operations on Local Variables Only¶
# List local variables
fmutool -input module.fmu -only-locals -dump-csv locals.csv
# Remove all local variables
fmutool -input module.fmu -only-locals -remove-all -output module-no-locals.fmu
Binary Operations¶
Remove Sources¶
Effect: The sources/ folder is removed from the FMU.
Extract Model Descriptor¶
Effect: Saves the modelDescription.xml file to the specified path. This can be combined with other operations.
Add Binary Interface (Windows)¶
Add 64-bit interface to 32-bit FMU:
Add 32-bit interface to 64-bit FMU:
Combining Operations¶
Options can be combined for complex transformations:
Example 1: Clean and Simplify¶
fmutool -input module.fmu \
-remove-regexp "^_internal.*" \
-remove-toplevel \
-remove-sources \
-output module-clean.fmu
Example 2: Filter and Rename¶
fmutool -input module.fmu \
-keep-only-regexp "^Motor\." \
-rename-from-csv motor_names.csv \
-output module-motor-renamed.fmu
fmucontainer: Create Containers¶
For full documentation of the fmucontainer command (options, CSV/JSON/SSP formats, Python API), see the dedicated FMU Container page.
Quick Reference¶
# Build container from CSV with 0.1s step size
fmucontainer -container container.csv:0.1
# Build from JSON with FMUs in a specific directory
fmucontainer -container assembly.json -fmu-directory ./my_fmus
# FMI 3.0 with multi-threading and profiling
fmucontainer -container assembly.json -fmi 3 -mt -profile
fmusplit: Extract FMUs from a Container¶
The fmusplit command extracts the embedded FMUs and the assembly description from a container FMU.
Basic Syntax¶
This creates a directory container.dir/ containing:
- All embedded
.fmufiles - The JSON assembly description (
container.json)
Options¶
| Option | Description |
|---|---|
-fmu filename.fmu | FMU container to split. Can be specified multiple times. |
-debug | Enable verbose logging during the split process. |
Example¶
# Split a single container
fmusplit -fmu my_container.fmu
# Split multiple containers
fmusplit -fmu container1.fmu -fmu container2.fmu
datalog2pcap: Convert Datalog to PCAP¶
Experimental
This tool is still experimental. The interface may change in future versions.
The datalog2pcap command converts CAN bus datalog CSV files (produced by FMU containers with the -datalog option and LS-BUS enabled FMUs) into PCAP files for analysis in tools like Wireshark.
Basic Syntax¶
Options¶
| Option | Description |
|---|---|
-can filename.csv | Datalog CSV file with CAN data and clocks. |
-debug | Enable verbose logging. |
Automation and Scripts¶
Simple Bash Script¶
#!/bin/bash
# Process all FMUs in a directory
for fmu in *.fmu; do
echo "Processing $fmu..."
fmutool -input "$fmu" \
-remove-toplevel \
-remove-sources \
-output "processed_$fmu"
done
echo "All FMUs processed!"
Batch Script (Windows)¶
@echo off
for %%f in (*.fmu) do (
echo Processing %%f...
fmutool -input "%%f" -remove-toplevel -output "processed_%%f"
)
echo All FMUs processed!
Quick Reference¶
# Analysis
fmutool -input X.fmu -summary # Summary
fmutool -input X.fmu -check # Verification
fmutool -input X.fmu -dump-csv list.csv # List ports
# Simple modification
fmutool -input X.fmu -remove-toplevel -output Y.fmu
fmutool -input X.fmu -merge-toplevel -output Y.fmu
# Renaming
fmutool -input X.fmu -rename-from-csv names.csv -output Y.fmu
# Filtering
fmutool -input X.fmu -keep-only-regexp "PATTERN" -output Y.fmu
fmutool -input X.fmu -remove-regexp "PATTERN" -output Y.fmu
# By type
fmutool -input X.fmu -only-parameters -dump-csv params.csv
fmutool -input X.fmu -only-inputs -dump-csv inputs.csv
fmutool -input X.fmu -only-outputs -dump-csv outputs.csv
fmutool -input X.fmu -only-locals -dump-csv locals.csv
# Extraction / Binaries (Windows)
fmutool -input X.fmu -extract-descriptor modelDescription.xml
fmutool -input X.fmu -add-remoting-win64 -output Y.fmu
fmutool -input X.fmu -remove-sources -output Y.fmu
# Containers
fmucontainer -container config.json -fmu-directory ./fmus
fmusplit -fmu container.fmu
# Datalog conversion (experimental)
datalog2pcap -can datalog.csv
Next Steps¶
- 🐍 Python API - Advanced automation
- 💡 Examples - Detailed use cases
- 🆘 Troubleshooting