-
Notifications
You must be signed in to change notification settings - Fork 193
Add topic on MAVLink C library #defines #492
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
Open
hamishwillee
wants to merge
4
commits into
master
Choose a base branch
from
defines
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.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 file contains hidden or 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# MAVLink C Library #defines | ||
|
||
The following C `#defines` can be set in code in order to tune the setup for use on different platforms. | ||
|
||
- `MAVLINK_USE_CONVENIENCE_FUNCTIONS` ([protocol.h](https://github.com/ArduPilot/pymavlink/blob/master/generator/C/include_v2.0/protocol.h)): Causes convenience functions to be defined, including: `_mav_finalize_message_chan_send()`, `_mavlink_send_uart()`, `_mavlink_resend_uart()`. | ||
Library users may choose not to set this and roll out their own implementations for efficiency (or other) reasons. | ||
- `MAVLINK_COMM_NUM_BUFFERS`: Sets the maximum number of comms buffers to be used (comms channels). | ||
By default this is set to 16 on Linux, Windows and macOS, and to 4 on other platforms. | ||
You might set `#define MAVLINK_COMM_NUM_BUFFERS 2` on an embedded system that would only ever have two channels, in order to reduce memory overheads. | ||
A stack overrun will occur if there are more buffers used than allocated. | ||
See [FAQ > How can I further reduce the generated C library size?](../about/faq.md#developers). | ||
- `MAVLINK_SIGNING_FLAG_SIGN_OUTGOING` ([mavlink_types.h](https://github.com/ArduPilot/pymavlink/blob/master/generator/C/include_v2.0/mavlink_types.h)): Enable/disable outgoing signing. | ||
See [Enabling Signing on a Channel > Enabling Signing on a Channel](../mavgen_c/message_signing_c.md#enabling_signing_channel) | ||
- `MAVLINK_EXTERNAL_RX_STATUS` ([mavlink_helpers.h](https://github.com/ArduPilot/pymavlink/blob/master/generator/C/include_v2.0/mavlink_helpers.h)): `mavlink_status_t* mavlink_get_channel_status(uint8_t chan)` returns the status of a particular channel using a preallocated `static` array. | ||
Define `MAVLINK_EXTERNAL_RX_STATUS` if you want to use your own external array (named `m_mavlink_status`) of `mavlink_status_t` objects. | ||
- `MAVLINK_EXTERNAL_RX_BUFFER` ([mavlink_helpers.h](https://github.com/ArduPilot/pymavlink/blob/master/generator/C/include_v2.0/mavlink_helpers.h)): Set if you want to define your own channel comms buffers on the stack or heap, rather than using the pre-allocated `static` buffers. | ||
If you define this you will need to declare an array of `mavlink_message_t` (one for each channel) named `m_mavlink_buffer`. | ||
- `NATIVE_BIG_ENDIAN` ([protocol.h](https://github.com/ArduPilot/pymavlink/blob/master/generator/C/include_v2.0/protocol.h)): Enable if using MAVLink on a system that is native big-endian (MAVLINK_LITTLE_ENDIAN is true by default). | ||
- `MAVLINK_SEPARATE_HELPERS` ([protocol.h](https://github.com/ArduPilot/pymavlink/blob/master/generator/C/include_v2.0/protocol.h)): Set to remove all the helpers declared `mavlink_helpers.h`, allowing you to provide an alternative implementation. | ||
- `MAVLINK_MAX_PAYLOAD_LEN`: Override the maximum payload length. | ||
The default maximum payload length is 255 bytes. With care you can override this to reduce the size, and hence memory usage (note, the maximum size cannot be increased as it is stored in a `uint8_t). | ||
For example, to reduce the maximum payload to the smallest size supported by a dialect you could do: | ||
hamishwillee marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
```c | ||
#include <version.h> | ||
#define MAVLINK_MAX_PAYLOAD_LEN MAVLINK_MAX_DIALECT_PAYLOAD_SIZE | ||
``` | ||
|
||
See also [FAQ > How can I further reduce the generated C library size?](../about/faq.md#developers). | ||
|
||
|
||
There are a number of other internal defines that should not be modified. |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would I be correct in thinking that you might specify
1
if you knew you had a mavlink component that would only have one connection to the network?