-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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
AP_PiccoloCAN: Remove duplicated code #17971
AP_PiccoloCAN: Remove duplicated code #17971
Conversation
amilcarlucas
commented
Jul 8, 2021
•
edited
Loading
edited
35013f8
to
890706d
Compare
This one is conflicting badly now, but still seems to be relevant - the duplicate code is still present in PiccoloCAN. We've had some recent activity in that directory - maybe we can drum up some interest. @SchrodingersGat - this PR removes some code from PiccoloCAN by leveraging the ESC Telemetry library, and there's a few advantages in doing that - chiefly "less code is good code" |
@peterbarker do you refer to removing the |
890706d
to
9896604
Compare
Rebased, please review again. |
69c7a60
to
8056237
Compare
What's with all the ! and <! stuff? |
Half the code had Doxygen comments, half did not. |
@SchrodingersGat can you take it from here? |
@SchrodingersGat is this going to bitrot again? |
@amilcarlucas I'll check it out |
This will probably conflict with #26252 so you better do it before that one gets merged. |
if (decodeServo_StatusAPacketStructure(&frame, &status.statusA)) { | ||
newTelemetry = true; | ||
} else if (decodeServo_StatusBPacketStructure(&frame, &status.statusB)) { | ||
AP_ESC_Telem_Backend::TelemetryData t { | ||
.voltage = float(servo.statusB.voltage) * 0.01f, | ||
.current = float(servo.statusB.current) * 0.01f, | ||
.consumption_mah = 0.0f, | ||
.usage_s = 0, | ||
.last_update_ms = 0, | ||
.temperature_cdeg = int16_t(servo.statusB.temperature * 100), | ||
}; | ||
|
||
update_telem_data(addr, t, | ||
AP_ESC_Telem_Backend::TelemetryType::CURRENT | ||
| AP_ESC_Telem_Backend::TelemetryType::VOLTAGE | ||
| AP_ESC_Telem_Backend::TelemetryType::TEMPERATURE); | ||
newTelemetry = true; | ||
} else if (decodeServo_FirmwarePacketStructure(&frame, &settings.firmware)) { | ||
} else if (decodeServo_AddressPacketStructure(&frame, &settings.address)) { |
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.
Looks like this addition is breaking the compile currently.
This change shouldn't be needed as:
- Servo data is already being logged in AP_PiccoloCAN.cpp
- Currently other CAN servos (DroneCAN, etc.) aren't reporting voltage/current/temp/etc. over the ESC telem backend for mavlink anyway
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.
Thanks, fixed
@amilcarlucas we have reviewed and tested locally (after fixing compiling issues). With the changes suggested by @reilly-callaway above, we would be happy with this. |
Fix doxygen markup for consistency Fix typos
8056237
to
8e4f4cc
Compare
Please approve so that this can get merged once the tests pass. |
@peterbarker are you OK with the current changes? |
68fd962
to
10c7b02
Compare
Can someone re-trigger the failing sub test? |
Merged, thanks! |
@amilcarlucas thanks for the work on this |