CommsDSL Specification
  • Introduction
  • Version
  • Schema Definition
  • Multiple Files
  • Namespaces
  • Platforms
  • References
  • Properties
  • Numeric Values
  • Boolean Values
  • Names
  • Protocol Versioning
  • Schema
  • Fields
    • Common Properties of Fields
    • enum Field
    • int Field
    • set Field
    • bitfield Field
    • bundle Field
    • string Field
    • data Field
    • list Field
    • float Field
    • ref Field
    • optional Field
    • variant Field
    • Referencing Values of Other Fields
  • Messages
  • Interfaces
  • Aliases
  • Frames
    • Common Properties of Layers
    • payload Layer
    • id Layer
    • size Layer
    • sync Layer
    • checksum Layer
    • value Layer
    • custom Layer
  • Protocol Versioning Summary
  • Appendix
    • Properties of schema
    • Common Properties of Fields
    • Properties of enum Field
    • Properties of int Field
    • Properties of set Field
    • Properties of bitfield Field
    • Properties of bundle Field
    • Properties of string Field
    • Properties of data Field
    • Properties of list Field
    • Properties of float Field
    • Properties of ref Field
    • Properties of optional Field
    • Properties of variant Field
    • Units
    • Properties of message
    • Properties of interface
    • Properties of alias
    • Properties of frame
    • Common Properties of Layers
    • Properties of checksum Layer
    • Properties of value Layer
    • Properties of custom Layer
Powered by GitBook
On this page
  • Referencing the Field
  • Length in Bits

Was this helpful?

  1. Fields

ref Field

This field serves as reference (alias) to other fields. It can be used to avoid duplication of field definition for multiple messages.

<?xml version="1.0" encoding="UTF-8"? version="10">
<schema ...>
    <fields>
        <int name="SomeIntField" type="uint8" defaultValue="Special2">
            <displayName value="Some Int Field" />
            <special name="Special1" val="0" />
            <special name="Special2" val="0xff" />
        </int>
    </fields>

    <message name="Msg1" id="1">
        <ref field="SomeIntField" />
        ...
    </message>

    <message name="Msg2" id="2">
        <ref field="SomeIntField" name="RenamedIntField" />
    </message>
</schema>

Referencing the Field

Length in Bits

<?xml version="1.0" encoding="UTF-8"?>
<schema name="MyProtocol" endian="big">
    <fields>
        <enum name="SomeEnum type="uint8">
            <validValue name="V1" val="0" />
            <validValue name="V2" val="1" />
            <validValue name="V3" val="2" />
        </enum>

        <bitfield name="SomeBitfield">
            <int name="SomeIntMember" type="uint8" bitLength="3" />
            <set name="SomeSetMember" bitLength="3">
                ...
            </set>
            <ref field="SomeEnum" bitLength="2" />
        </bitfield>
    </fields>
</schema>
Previousfloat FieldNextoptional Field

Last updated 5 years ago

Was this helpful?

The <ref> field has all the properties. It also copies name, displayName and semanticType from the referenced field and allows overriding them with new values. Note, that in the example above <ref> field defined as a member of Msg1 message hasn't provided any name value. It is allowed because it has taken a name of the referenced field (SomeIntField).

The only extra property the <ref> field has is field to specify a to other field.

Since v2 of this specification it is allowed to use <ref> field as member of the field while referencing one of the allowed member types. In such case it is required to use bitLength property to specify length in bits.

Use for future references.

common
properties
reference
<bitfield>
properties table