Metadata handling#
- group Metadata handling
Handle JSON-formatted metadata.
Enums
-
enum jsdrv_meta_flag_e#
Metadata flag bits (mirrors minibitty’s mb_pubsub_meta_flags_e).
Values:
-
enumerator JSDRV_META_FLAG_RO#
Topic is read-only; cannot be updated by the host.
-
enumerator JSDRV_META_FLAG_HIDE#
Topic should not appear in the user interface.
-
enumerator JSDRV_META_FLAG_DEV#
Developer option; not for production use.
-
enumerator JSDRV_META_FLAG_RO#
Functions
-
int32_t jsdrv_meta_syntax_check(const char *meta)#
Check the JSON metadata syntax.
- Parameters:
meta – The JSON metadata.
- Returns:
0 or error code.
-
int32_t jsdrv_meta_dtype(const char *meta, uint8_t *dtype)#
Get the data type.
- Parameters:
meta – The JSON metadata.
dtype – [out] The jsdrv_union_e data type.
- Returns:
0 or error code.
-
int32_t jsdrv_meta_default(const char *meta, struct jsdrv_union_s *value)#
Get the default value.
- Parameters:
meta – The JSON metadata.
value – [out] The parsed default value.
- Returns:
0 or error code.
-
int32_t jsdrv_meta_value(const char *meta, struct jsdrv_union_s *value)#
Validate a parameter value using the metadata.
- Parameters:
meta – The JSON metadata.
value – [inout] The value, which is modified in place.
- Returns:
0 or error code.
-
int32_t jsdrv_meta_flags(const char *meta, uint32_t *flags)#
Get the flags bitmask from the metadata.
Parses the “flags” key from the JSON metadata, which is a list of string tokens: “ro”, “hide”, “dev”. Returns a bitmask of jsdrv_meta_flag_e. If “flags” is absent, *flags is set to 0.
- Parameters:
meta – The JSON metadata.
flags – [out] The resulting bitmask.
- Returns:
0 or error code.
-
enum jsdrv_meta_flag_e#
Host-side metadata#
The driver defines its own topic metadata, such as JS320 h/fs and the
memory buffer m/ topics, in jsdrvp_param_s tables in
src/**/*_params.c. Tables in src/devices/<model>/ apply to that
device model. Other tables are global driver topics. Topics may contain
{buf} and {sig} placeholders for the buffer and signal ids.
pyjoulescope_driver.metadata_extract parses these tables into the
packaged host_params.json. After editing a table, regenerate it with:
python -m pyjoulescope_driver.metadata_extract --write
A unit test fails when host_params.json is stale.
The metadata entry point combines this host-side metadata with the
firmware build’s pubsub_metadata.json files to document all topics
without a device:
python -m pyjoulescope_driver metadata --firmware js320.zip --out js320.html
With a connected device, --diff compares the live metadata against a
saved JSON file to verify the offline output:
python -m pyjoulescope_driver metadata --diff js320.json