Skip to main content

ModDef

Declarative Modbus device definitions: one schema, every language

Describe the device once

A ModDef document is a declarative map of a device's Modbus registers: storage types, byte order, scaling, sentinels, write constraints, and the semantic measurand each point reports. It is the same file whether you read it from Go, TypeScript, Rust, Python, C, or C++.

No hand-written register offsets scattered across firmware. No re-deriving the scale factor in three codebases. The definition is the source of truth; every runtime decodes it identically.

# growatt-sph.moddef.yaml: one definition, every runtime
- point_id: pv1_voltage
storage_type: U16
value_type: { primitive: DECIMAL }
mapping: { space: INPUT_REGISTER, offset: 3 }
transform: { scale: { numerator: 1, denominator: 10 } }
measurand: { base_quantity: voltage }

Use it from your stack

Load the definition, bind a transport, and read a point by name. The runtime applies the offset, scaling, byte order, and sentinels from the document, so you never repeat them in code. The same call returns 230.5 in every language.

Or query by meaning with a measurand (“grid frequency”, “L1-N voltage”) and let the runtime find the point.

doc, _ := moddef.Load("growatt-sph.moddef.yaml")
dev, _ := client.New(doc, "growatt-sph", transport)
v, _ := dev.ReadPoint(ctx, "pv1_voltage")
fmt.Println(v) // 230.5

Idiomatic in every language

One schema, six implementations that share a conformance suite. Pick the SDK your stack already speaks.