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

DroneCAN: added FlexDebug support #28450

Merged
merged 4 commits into from
Nov 5, 2024

Conversation

tridge
Copy link
Contributor

@tridge tridge commented Oct 23, 2024

This allows lua scripts to receive FlexDebug DroneCAN messages, allowing for flexible arbitrary debug data from peripheral nodes
This was developed for debugging AM32 ESCs, but any vendor can reserve ranges of IDs

libraries/AP_DroneCAN/AP_DroneCAN.cpp Show resolved Hide resolved
libraries/AP_DroneCAN/AP_DroneCAN.h Outdated Show resolved Hide resolved
libraries/AP_Scripting/lua_bindings.cpp Outdated Show resolved Hide resolved
modules/DroneCAN/DSDL Outdated Show resolved Hide resolved
libraries/AP_Scripting/lua_bindings.cpp Outdated Show resolved Hide resolved
libraries/AP_DroneCAN/AP_DroneCAN.cpp Show resolved Hide resolved
const uint8_t bus = get_uint8_t(L, 1);
const uint8_t node_id = get_uint8_t(L, 2);
const uint16_t msg_id = get_uint16_t(L, 3);
uint32_t tstamp_us = get_uint32(L, 4, 0, UINT32_MAX);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
uint32_t tstamp_us = get_uint32(L, 4, 0, UINT32_MAX);
uint32_t tstamp_us = coerce_to_uint32_t(L, 4);

Don't need the range check.

Copy link
Contributor

@tpwrules tpwrules left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, tested it with an AM32 ESC and it does what it says on the tin. We can keep the binding as it is now, with the understanding that we may change it in the future.

Happy the option bit has been added as a safety/abuse prevention.

Not thrilled with the lack of locking/atomics, but that is a general concern I have with ArduPilot and I think it's correct in an ideal world as it is. Flash cost is about 1K on CubeOrange which seems reasonable enough.

@tridge tridge merged commit 7f04c82 into ArduPilot:master Nov 5, 2024
100 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants