Giter Club home page Giter Club logo

Comments (4)

arobenko avatar arobenko commented on July 4, 2024

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.

KhaledEmaraDev avatar KhaledEmaraDev commented on July 4, 2024

@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.

arobenko avatar arobenko commented on July 4, 2024

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.

KhaledEmaraDev avatar KhaledEmaraDev commented on July 4, 2024

Thank you so much @arobenko again for the prompt response. This more than solves my problem.

from commsdsl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.