-
Notifications
You must be signed in to change notification settings - Fork 31
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
Generate tables for libcanard table coding system #30
Open
tpwrules
wants to merge
8
commits into
dronecan:master
Choose a base branch
from
tpwrules:pr/table-coding
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This allows the entry point to be inlined at the caller site, paving the way for various optimizations. <msg>_encode now calls the non-inlined _<msg>_encode function in the .c file which does the preliminary work then calls __<msg>_encode to encode the actual type, if compound (or e.g. canardEncodeScalar).
Allows the processing of 0-length messages (which is true of some important ones in the DSDL) to be optimized away.
If the message structure is compatible, the compiler generates a table which describes the structure. If enabled, an interpreter in libcanard is then used to follow the table description and encode or decode the message. This occupies substantially fewer bytes per message as the table is much smaller than the C function previously used. This translates to a large reduction in program memory usage, especially if many different message types need to be coded. The call to the interpreter (along with a pointer to the message and the associated table) is inlined whereever e.g. <msg>_encode is called. The existing function to encode/decode is still generated in case table coding is not enabled in libcanard or the structure is not compatible. This commit sets up all the hooks to generate the tables and call the interpreter functions. However, no tables are generated as the generation function is a simple stub that always fails.
Each table has a four byte header, plus some number of entries (4 bytes). Each field consumes one entry. The maximum encoded message length in bytes, size of the C message struct in chars, and number of table entries all are limited to 65535 for table coding to be possible.
There is no additional overhead for nesting.
Static arrays have a 2-entry header (8 bytes), plus the entries describing the contents of the array. Array contents cannot consist of more than 256 entries (including header entries and entries describing nested types). The array length cannot exceed 65535.
Dynamic arrays have a 3-entry header (12 bytes), plus the entries describing the contents of the array. Array contents cannot consist of more than 256 entries (including header entries and entries describing nested types). The maximum array length cannot exceed 65535.
Unions have a 2-entry header (8 bytes), plus 1 entry for each field, plus the entries describing each field. The maximum number of fields is 255. Each field cannot consist of more than 255 entries (including header entries and entries describing nested types). This completes the list of DSDL types.
This was referenced Jul 26, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Please see individual commit messages for details.
Please also see the main discussion at libcanard.