Creating Frame with `id` that is less than one byte
I am working on a protocol where the message id is just 5 bits and remaining 3 bits is part of the message itself.
I couldn't find a way to implement such a thing using the tutorials.
Is there a possibile way to do such a thing?
tutorial17 does't describe my case.
Assume i have a message something like this | id 6 bits | name 7 bits | status 3 bits |
so the id of the message in that case is less than one byte.
is there a way to make the frame less than one byte?
Unfortunately the CommsChampion Ecosystem is a poor fit for the bit based protocols. It was designed to handle byte based ones. There is a limited support for bit based fields when they are bundled together in the <bitfield> field, which has its limitations. It requires total number of bits to be divisible by 8 (i.e. have a byte-based total length) and cannot exceed 64 bit altogether to be able to fit into 64 bit of underlying type, such as std::uint64_t.
If the fields listed above (| id 6 bits | name 7 bits | status 3 bits |) are the same for all the messages, i.e. can be considered to be part of the message framing, then you can solve it by defining a <custom> framing layer with the <bitfield> field combining these fields:
<custom name="IdWithExtras" semanticLayerType="id">
<bitfield name="Field" endian="big">
<int name="Status" type="uint8" bitLength="3">
<int name="Name" type="uint8" bitLength="7" />
<int name="Id" type="uint8" bitLength="6" />
</bitfield>
</custom>
Then you can use tutorial17 for the guidance of how to implement such custom layer extending the comms::protocol::MsgIdLayer.
If this is not your case, then I'm afraid you should look for other solutions instead of (or in addition to) the CommsChampion Ecosystem.
I have some thoughts and ideas of how I can support the bit based protocols in the CommsChampion Ecosystem, but I'm not planning to work on it in the near future.