This section describes the data-type model used for eBUS payload decoding and encoding.
Each data type exposes a common interface:
type Value struct {
Value any
Valid bool
}
type DataType interface {
Decode([]byte) (Value, error)
Encode(any) ([]byte, error)
Size() int
ReplacementValue() []byte
}Value.Valid == truemeans the payload represented a concrete value.Value.Valid == falsemeans the payload is not a usable value for the type, either because it matched the replacement value or because the type-specific decoder rejected it (e.g., NaN/Inf or out-of-range forEXP).
Replacement values are defined per type and are used by devices to indicate “unknown” or “not available.”
Each type defines a byte sequence returned by ReplacementValue(). When decoding:
- If the payload equals the replacement value,
Validis false andValueis unset. - Otherwise, the decoder may still set
Validto false if the decoded value is invalid for that type (for example,EXPtreats NaN/Inf as invalid). - If the value is acceptable,
Validis true andValuecontains the decoded value.
When encoding:
- Values that would encode to the replacement value are rejected.
- Inputs outside the valid range are rejected.
This keeps “unknown” distinct from legitimate numeric values without using sentinel numbers in application code.
types/ebusd-csv.md– common ebusd CSV type spec strings and selector conventions (observed).