Ambiorix ODL reference: syntax, attributes, resolvers and parse order (handbook)
Grow through practice
No need to finish reading — test nowThis 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:
| Directive | Purpose |
|---|---|
%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;andkey += value;; - values: string/bool/int/list/htable;
${name}from config,$()from environment;- precedence: defaults →
-o→%config→-F.
3. %define: objects and parameters
Object attributes
| Attribute | Effect |
|---|---|
%read-only | template object: clients cannot add/delete instances |
%persistent | persist |
%private | invisible to clients (owner only) |
%protected | internal use (not exposed to remote management) |
% sets, ! unsets (in %populate).
Parameter attributes
| Attribute | Effect |
|---|---|
%read-only | clients cannot set |
%persistent | persist |
%private / %protected | visibility |
%template / %instance | template/instance only |
%volatile | no change events; use on action read for computed values |
%key | instance key (in templates) |
%unique | value must be unique |
%write-once | can 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:
| Attribute | Effect |
|---|---|
%in | input (default) |
%out | output |
%mandatory | required |
%strict | exact type required |
Function attributes: %private, %protected, %template, %instance, %async.
Events
event 'MyEvent!';
void send_event(%in %mandatory variant data);
Action callbacks
| Action | Trigger |
|---|---|
read | read parameter/object |
write | write parameter |
validate | validate before write |
list | list instances/objects |
describe | introspection |
destroy | destroy |
add-inst / del-inst | add/delete instance |
translate / apply | sync/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/synchronizeare covered in the official docs.
5. Resolvers: how ODL finds C functions
Three resolvers:
| Resolver | Mechanism |
|---|---|
| auto (default) | tries ftab → import → others in order |
| ftab | function table (amxo_resolver_ftab_add) |
| import | dlopen + 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
| Symptom | Check |
|---|---|
${name} becomes amxrt | -o name=xxx / symlink |
_xxx not found | import-dbg = true; check .so/symbol |
| object missing | is %define included? |
| instance missing | is %populate included? key assigned? |
| read-only write fails | %read-only / !read-only |
| empty path | undefined ${} → empty string |
8. Checklist for reading any ODL
%config:name, paths, include/import dirs;
import: which.so;
include: are definition/defaults/extra actually loaded?
%define: object tree, params, functions, events;
%populate: instances, defaults, events;
- resolver instructions:
<!...!>;
entry-point: the entry function.
9. Verification matrix
| Claim | Basis |
|---|---|
%config → parser->config | amxo_parser.y + amxo_parser_main.c + -dconfig |
-o < %config < -F | measured with -dconfig |
#include optional / &include post | official odl.md include section |
%volatile sends no events | official 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 → slot | amxo_parser_dm_utils.c (amxp_slot_connect*) |
| entry-point | libamxrt/src/amxrt.c (invoke) |
check_* built-in | official odl.md ftab list |
check_change not built-in | greeter dm_greeter_actions.c + main.c registration |
10. Source map
| Topic | Official doc | Source |
|---|---|---|
| File structure | odl.md ODL Files | amxo_parser.y |
%config | odl.md Section %config | amxo_parser_main.c |
%define | odl.md Section %define | amxo_parser_dm_utils.c |
%populate | odl.md Section %populate | amxo_parser_dm_utils.c |
| Attributes | odl.md Appendix B | libamxd/include/amxd/amxd_types.h |
| Resolvers | odl.md Function Resolving | amxo_import_resolver.c / amxo_ftab_resolver.c |
| Types/keywords | odl.md Appendix C | amxo_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)
| Question | Official wording | My verification/conclusion | Status |
|---|---|---|---|
-o vs %config precedence | -o is an option | ODL overrides -o; -F overrides ODL | ✅ measured |
${name} default | not emphasized | running amxrt directly gives amxrt; it looks for amxrt.so | ✅ measured |
#include vs &include | optional vs post | optional 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_change | not in the built-in ftab list | registered by greeter (_State_check_change) | ✅ source |
instance add(0,"") index 0 | index must be unique | whether 0 means “auto index” is unconfirmed | ❓ open |
check_minimum_length mapping | doc says it maps to check_minimum | likely a doc typo | ❓ open |
&include vs entry-point order | loaded after START | not 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
%configand%defineare 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
%populateis 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.
Comments 0
No comments yet — be the first!