set Field
Last updated
Was this helpful?
Last updated
Was this helpful?
This field stores and abstracts away value of bitset (bitmask) type. The <set> field has all the properties as well as extra properties and elements described below.
The underlying type of the <set> field can be provided its underlying storage type using type . Available values are:
uint8 - 1 byte unsigned integer.
uint16 - 2 bytes unsigned integer.
uint32 - 4 bytes unsigned integer.
uint64 - 8 bytes unsigned integer.
NOTE that the available types are all fixed length unsigned ones.
The code generator is expected to generate convenience functions (or other means) to set / get the value of every listed bit.
description - Extra description and documentation on the bit.
displayName - String specifying how to name the bit in various analysis tools.
The SomeSetField field from the example above is expected to be initialized to 0xff when default constructed.
The defaultValue may also be specified per-bit, which overrides the defaultValue specified for the whole field.
The SomeSetField field from the example above is expected to be initialized to 0xfe when default constructed.
All the bits that aren't listed as <bit> XML child elements are considered to be reserved. By default every reserved bit is expected to be zeroed when field is checked to have a valid value. Such expectation can be changed using reservedValue property.
The SomeSetField field from the example above is expected to be initialized to 0xfc and all the reserved (non-listed) bits are expected to remain true.
The example above marks bit 2 to be reserved, that is initialized to true and must always stay true.
The SomeSetField field from the example above is expected to be initialized to 0x04 when default constructed.
sinceVersion - Version of the protocol when the bit was introduced (became non-reserved).
deprecated - Version of the protocol when the value was deprecated (became reserved again).
In the example above bits 0 and 5 will always have valid values. However bit 10 will be considered valid only if it is cleared before version 2, and may have any value after. The bit 15 will be allowed any value when version 3 of the protocol is reported, and must be cleared for any other version.
The specification may be omitted if serialization length (in number of bytes) is specified using length property. In this case is automatically selected based on the provided serialization length.
<set> field can be a member of field. In this case the serialization length may be specified in bits using bitLength .
NOTE that the information can be omitted when bitLength property is in use, just like with length.
The <set> field may list its bits as <bit> XML child elements. Every such element must specify its using name property as well as its index using idx property.
The bit indexing starts from least significant bit, and mustn't exceed number of bits allowed by the . The <bit>-s may be listed in any order, not necessarily sorted.
Every <bit> element may also define extra listed below for better readability:
These properties are described in detail in .
When the <set> field object is default constructed, all bits are initialized to false, i.e. 0. Such default behavior can be modified using defaultValue with value.
Reserved bits can also be specified as <bit> XML child element with usage of reserved with value.
The default serialization endian of the protocol is specified in endian property of the . It is possible to override the default endian value with extra endian property.
By default, having multiple names for the same bit is not allowed, the code generator must report an error if two different <bit>-s use the same value of idx property. It is done as protection against copy-paste errors. However, CommsDSL allows usage of multiple names for the same bit in case nonUniqueAllowed has been set to true.
In addition to mentioned earlier , every <bit> element supports extra ones for versioning:
These extra properties are described in detail in .
The code generator is expected to generate functionality checking that <set> field contains a valid value. Any specified non-reserved bit can have any value, while reserved bits (implicit or explicit) must have value specified by reservedValue property (either of the field or the bit itself). By default, the validity check must ignore the version in which particular bit became reserved / non-reserved, and check only values of the bits that have always stayed reserved. However, it is possible to force code generator to generate validity check code that takes into account reported version of the protocol by using validCheckVersion , which is set to true.
Use for future references.