← All posts

Ambiorix ODL reference: syntax, attributes, resolvers and parse order (handbook)

Grow through practice

No need to finish reading — test now

This is the handbook: not one example, but the full list of ODL syntax, attributes, types, resolvers and parse order. For walkthroughs, see part 1 and part 2.

Version/source (traceable) - Official doc: libamxo doc/odl.md - Source: amxo_parser.y, amxo_parser.l, amxo_parser_main.c, amxo_parser_dm_utils.c, amxo_parser_dm_param_utils.c, amxo_import_resolver.c - Measured: libamxo v5.7.1 (f64456b), libamxd v6.11.2 (94ff82a), libamxb 4.17.2, amxb_ubus 3.11.1, amxrt 2.6.1, Ubuntu 22.04 - This is not official documentation; the goal is “lookup-able, reproducible, sourced”. If anything differs, official wins.

How this differs from the official docs: the official docs tell you “what”; this adds three things — how I verified it, what is still uncertain, and why it is designed this way.

1. ODL file structure

Top-level directives:

DirectivePurpose
%config { ... }parser/runtime config
%define { ... }object tree, functions, events
%populate { ... }instances, defaults, event handlers
include "x.odl";recursive parse
#include "x.odl";optional include; missing is OK
?include "a":"b";conditional include / fallback
&include "x.odl";post include; loaded after entry-point START
import "x.so" [as "alias"];load a shared object
requires "x";declare a dependency
print "text";print during parsing

2. %config

  • stored in parser->config (htable);
  • supports key = value; and key += value;;
  • values: string/bool/int/list/htable;
  • ${name} from config, $() from environment;
  • precedence: defaults → -o → %config → -F.

See how %config is parsed.

3. %define: objects and parameters

Object attributes

AttributeEffect
%read-onlytemplate object: clients cannot add/delete instances
%persistentpersist
%privateinvisible to clients (owner only)
%protectedinternal use (not exposed to remote management)

% sets, ! unsets (in %populate).

Parameter attributes

AttributeEffect
%read-onlyclients cannot set
%persistentpersist
%private / %protectedvisibility
%template / %instancetemplate/instance only
%volatileno change events; use on action read for computed values
%keyinstance key (in templates)
%uniquevalue must be unique
%write-oncecan be written only once

Types

bool, string, csv_string, ssv_string, int8/16/32/64, uint8/16/32/64, double, datetime, fd, htable, list, variant, void.

Special parameters

  • counted with CountParam: auto-maintained instance counter;
  • %unique %key string Alias: TR-181-style Alias;
  • key parameters must be assigned in instance add.

Functions

string say(%in %mandatory string from,
           %in %mandatory string message,
           %in bool retain = false);

Argument attributes:

AttributeEffect
%ininput (default)
%outoutput
%mandatoryrequired
%strictexact type required

Function attributes: %private, %protected, %template, %instance, %async.

Events

event 'MyEvent!';
void send_event(%in %mandatory variant data);

Action callbacks

ActionTrigger
readread parameter/object
writewrite parameter
validatevalidate before write
listlist instances/objects
describeintrospection
destroydestroy
add-inst / del-instadd/delete instance
translate / applysync/apply

Built-in validators (ftab): check_minimum, check_minimum_length, check_maximum, check_maximum_length, check_range, check_enum, check_is_in, hide_value, verify_max_instances.

4. %populate

  • object Path { ... } selects an object;
  • instance add(index, name) { ... } adds an instance;
  • parameter P = value; sets a default;
  • !read-only parameter P = ...; temporarily bypasses read-only;
  • on event "..." call f filter '...' subscribes to events;
  • select / synchronize are covered in the official docs.

5. Resolvers: how ODL finds C functions

Three resolvers:

ResolverMechanism
auto (default)tries ftab → import → others in order
ftabfunction table (amxo_resolver_ftab_add)
importdlopen + dlsym, symbol _<name> / _<object>_<name>

Explicit instructions:

void ForceReconnect() <!ftab:dummy_impl!>;
variant echo(...) <!import:${name}:_function_dump!>;
  • <!ftab!> / <!import!> alone also work;
  • import instruction symbols are used without prefixing;
  • unresolved → warning, not necessarily fatal.

6. Parse order

amxo_parser_parse_file
  → %config
  → import (dlopen)
  → include (recursive)
  → %define (amxd_object_new/param_new)
  → %populate (add_instance/slot_connect)
  → entry-point (invoke)

7. Troubleshooting

SymptomCheck
${name} becomes amxrt-o name=xxx / symlink
_xxx not foundimport-dbg = true; check .so/symbol
object missingis %define included?
instance missingis %populate included? key assigned?
read-only write fails%read-only / !read-only
empty pathundefined ${} → empty string

8. Checklist for reading any ODL

  1. %config: name, paths, include/import dirs;
  1. import: which .so;
  1. include: are definition/defaults/extra actually loaded?
  1. %define: object tree, params, functions, events;
  1. %populate: instances, defaults, events;
  1. resolver instructions: <!...!>;
  1. entry-point: the entry function.

9. Verification matrix

ClaimBasis
%config → parser->configamxo_parser.y + amxo_parser_main.c + -dconfig
-o < %config < -Fmeasured with -dconfig
#include optional / &include postofficial odl.md include section
%volatile sends no eventsofficial odl.md attributes section
resolver _<name>amxo_import_resolver.c + import-dbg
object/param → amxd_*amxo_parser_dm_utils.c / ..._param_utils.c
on event → slotamxo_parser_dm_utils.c (amxp_slot_connect*)
entry-pointlibamxrt/src/amxrt.c (invoke)
check_* built-inofficial odl.md ftab list
check_change not built-ingreeter dm_greeter_actions.c + main.c registration

10. Source map

TopicOfficial docSource
File structureodl.md ODL Filesamxo_parser.y
%configodl.md Section %configamxo_parser_main.c
%defineodl.md Section %defineamxo_parser_dm_utils.c
%populateodl.md Section %populateamxo_parser_dm_utils.c
Attributesodl.md Appendix Blibamxd/include/amxd/amxd_types.h
Resolversodl.md Function Resolvingamxo_import_resolver.c / amxo_ftab_resolver.c
Types/keywordsodl.md Appendix Camxo_parser.y / .l

11. Corrections / updates

  • 2026-10-20: fixed #include (optional) and &include (post include), %volatile (only suppresses events), check_change (greeter-specific ftab).

12. Limits

  • Not every action/attribute was measured (especially translate / apply / synchronize);
  • greeter was only statically analyzed, not run on a PC;
  • ODL evolves with libamxo versions; attributes/keywords may change. Trust the version table.

13. Where the official docs are unclear (my experiments)

QuestionOfficial wordingMy verification/conclusionStatus
-o vs %config precedence-o is an optionODL overrides -o; -F overrides ODL✅ measured
${name} defaultnot emphasizedrunning amxrt directly gives amxrt; it looks for amxrt.so✅ measured
#include vs &includeoptional vs postoptional continues if missing; post loads after START⚠️ official doc (not measured separately)
%volatile“no events”only suppresses events; computed-on-read uses on action read⚠️ official doc
check_changenot in the built-in ftab listregistered by greeter (_State_check_change)✅ source
instance add(0,"") index 0index must be uniquewhether 0 means “auto index” is unconfirmed❓ open
check_minimum_length mappingdoc says it maps to check_minimumlikely a doc typo❓ open
&include vs entry-point orderloaded after STARTnot verified at runtime⚠️ official doc

14. Confidence levels

  • ✅ Source/measured: safe to rely on;
  • ⚠️ Official doc, but not separately measured: usable; run it yourself;
  • ❓ Open/unconfirmed: not a conclusion; experiments welcome.

15. Why it is designed this way (reasoning)

  • Why ODL has no business logic: declaration and implementation are separated; ODL stays readable/serializable, behavior stays in C for debugging/reuse.
  • Why %config and %define are separate: the former is runtime wiring (paths/backends/switches), the latter is the data model (objects/parameters); mixing them pollutes the model with configuration.
  • Why resolvers exist: ODL names are decoupled from C symbols; the same ODL can switch implementations (ftab/import) and is easy to mock.
  • Why %populate is separate: structure (%define) and defaults/instances (%populate) are separate; structure is reusable, defaults can be overridden per product.
  • Why ${} is expanded lazily: config values are “templates”; expansion happens when used, so include/import/install paths can be reused.

FAQ

ODL vs YANG?

YANG is a data modeling language (NETCONF); ODL is Ambiorix's object tree + function binding language for the C runtime.

Can ODL contain business logic?

No. Behavior must be in C; ODL only declares and binds.

Why the _ prefix?

The import resolver maps ODL names to _<name> or _<object>_<name> by default.

%template vs %instance?

%template is usable only on templates; %instance is inherited by instances; if neither is set, %instance is the default.

Do %volatile and %persistent conflict?

%volatile only means “no change events”; computed-on-read is done via on action read; %persistent means persist. They are usually not used together.

One sentence

ODL = three sections (config/define/populate) + directives (include/import/entry-point) + resolvers. Keep this table in mind and you can take apart any ODL in order.


Walkthroughs: part 1 amx-scheduler · part 2 greeter · %config Series: AMX Official Examples.

Practice

Found this useful?

I write about AI agents × embedded / edge AI. Subscribe, or email me a concrete problem.

Guestbook →Subscribe (RSS)Support

Comments 0

No comments yet — be the first!

No login required; name is optional.