data Field
Last updated
Was this helpful?
Last updated
Was this helpful?
This field stores and abstracts away value of a raw bytes data. The <data> field has all the properties as well as extra properties and elements described below.
Such definition of the <data> does NOT have any limit on the length of the data, and will consume all the available bytes in the input buffer.
The default value of the <data> field when constructed can be specified using defaultValue . The value of the property must be case-insestive string of hexadecimal values with even number of characters. The allowed ranges of the characters are: ['0' - '9'], and ['a' - 'f']. The ' ' (space) character is also allowed for convenient separation of the bytes. If not specified, defaults to empty data.
The example above is expected to create approprate raw data abstracting field, containing 8 bytes: [0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef] when default constructed.
In case the data value needs to be serialized using predefined fixed length, use length property to specify the required value.
The code generator is expected to take the existence of such detached prefix into account and generate correct code for various field operations (read, write, etc...).
NOTE, that length and lengthPrefix properties are mutually exclusive, i.e. cannot be used together.
Many protocols prefix raw binary data with its length. The CommsDSL allows definition of such prefix using lengthPrefix child element, which must define prefix as field.
In case the prefix field is defined as external field, CommsDSL allows usage of lengthPrefix as , value of which contains name of the referenced field.
The CommsDSL also supports detached length prefix, when there are several other fields in the or in the between the length field and the <data>.
NOTE, the existence of $ prefix when specifying lengthPrefix value. It indicates that the referenced field is a sibling in the containing or the field.
Use for future references.