Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Creating Frame with id that is less than one byte #22

Open
ahmed192a opened this issue Sep 6, 2023 · 3 comments
Open

Creating Frame with id that is less than one byte #22

ahmed192a opened this issue Sep 6, 2023 · 3 comments
Labels
question Further information is requested

Comments

@ahmed192a
Copy link

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?

@ahmed192a ahmed192a changed the title Creating scheme with id that is less than one byte Creating Frame with id that is less than one byte Sep 6, 2023
@arobenko
Copy link
Member

arobenko commented Sep 7, 2023

Hi Ahmed,
I think the tutorial17 is what you need.

Regards,
Alex

@arobenko arobenko added the question Further information is requested label Sep 7, 2023
@ahmed192a
Copy link
Author

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?

@arobenko
Copy link
Member

arobenko commented Sep 9, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants