Comments (4)
Maybe I don't understand exactly what you mean, but I think usage of the <termSuffix>
is sufficient in your case. Something like:
<list name="MyList" element="DataItem100>
<termSuffix>
<int name="Term" type="uint8" defaultValidValue="0" failOnInvalid="true" />
</termSuffix>
</list>
Unless zeroed FX bit indicates the last element in the list. In such case you need to write your custom read
, functions which read elements one by one, checks the FX bit after each iteration and terminates the loop if necessary. Maybe some other functions (like refresh
which sets the FX bit in all the list elements accordingly) also need to be implemented.
If I'm wrong, please clarify exactly what you need and why existing methods are insufficient.
from commsdsl.
@arobenko fx
indicates whether there is another element
in the list
or not.
My problem is that I believe termSuffix
to need the entire byte to be zero in order to terminate the list.
This is not the case in the protocol I'm implementing. Only the last bit determines this. So it maybe 0b00000000
or 0b00000010
or any other form that ends with the last bit = 0.
I think it might be doable with custom code as you mentioned. I was thinking that having cond
on lists
to implement the condition on which the loop should exit would be an easier way.
from commsdsl.
Hi @KhaledEmaraDev,
The COMMS library implements the logic behind the <termSuffix>
in the following way:
- Attempt to read the termination suffix field. If it's successful, the read operation successfully terminates.
- If the read operation of the termination suffix fails, then attempt to read list element from the same place.
- Repeat the operations above until the list is terminated or error on element read occurs.
It means that you need to define your <termSuffix>
in a way that fails if LSB is 1, and successful if it is 0. I think using the <set>
(with LSB defined as reserved) instead of <int>
as your termination suffix will do the job:
<termSuffix>
<set name="Term" length="1" failOnInvalid="true">
<!-- skip mention of first bit make it reserved -->
<bit name="B1" idx="1" />
<bit name="B2" idx="2" />
<bit name="B3" idx="3" />
<bit name="B4" idx="4" />
<bit name="B5" idx="5" />
<bit name="B6" idx="6" />
<bit name="B7" idx="7" />
</set>
</termSuffix>
Usage of the failOnInvalid property makes sure that the read operation fails when the reserved bit is set, as the result allowing your list to continue with the element read operation.
If you need to access the termination field's value after the read operation takes place you can use newly introduced (available on develop branch) terminationSuffixField() member function of the list field.
from commsdsl.
Thank you so much @arobenko again for the prompt response. This more than solves my problem.
from commsdsl.
Related Issues (20)
- Question: List without length and message size HOT 2
- ICD generation HOT 7
- Missing copyright holder in license HOT 5
- ASN.1 Parsing/Serialization HOT 2
- Adding constexpr to static const functions HOT 2
- Bit Order in `<bitfield>` and `<set>` HOT 4
- `optional` field with `cond` depending on another `optional` field. HOT 7
- Need Help HOT 21
- Creating Frame with `id` that is less than one byte HOT 3
- Can a (serial) protocol with character escaping be realized using the custom code feature? HOT 2
- Schema name cannot start with a capital HOT 4
- Select variant based on value in the transport frame HOT 1
- noexcept error with gcc 9 HOT 5
- Unexpected max serialisation length HOT 4
- Dead links in the Readme HOT 1
- vcpkg integration HOT 16
- error when using COMMSDSL_NO_TESTS HOT 2
- Undefined behaviour on "out of range" values of ID layer. HOT 4
- "Unexpected max serialisation length" on variable length field inside variant HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from commsdsl.