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

Avoid use of AP_Logger.h in library headers #27965

Merged
merged 2 commits into from
Sep 3, 2024

Conversation

peterbarker
Copy link
Contributor

this pulls in many more headers, we should avoid using it whereever we can

Board                    AP_Periph  blimp  bootloader  copter  heli  iofirmware  plane  rover  sub
CubeOrange-periph-heavy  *                                                                     
Durandal                            *      *           *       *                 *      *      *
Hitec-Airspeed           *                                                                     
KakuteH7-bdshot                     *      *           *       *                 *      *      *
MatekF405                           *      *           *       *                 *      *      *
Pixhawk1-1M-bdshot                  *                  *       *                 *      *      *
f103-QiotekPeriph        *                                                                     
f303-Universal           *                                                                     
iomcu                                                                *                         
revo-mini                           *      *           *       *                 *      *      *
skyviper-v2450                                         *                                       

@@ -250,7 +250,23 @@ void AP_AutoTune::update(AP_PIDInfo &pinfo, float scaler, float angle_err_deg)
#if HAL_LOGGING_ENABLED
if (now - last_log_ms >= 40) {
// log at 25Hz
struct log_ATRP pkt = {
const struct PACKED {
Copy link
Member

Choose a reason for hiding this comment

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

I would have expected this to be deleted from where ever it is now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, I remember now. We can't move the definition of this into the .cpp file. log_ATRP is included into ArduPlane's log structure:

SCB-WAF: [1166/1206] Compiling ArduPlane/mode.cpp../../ArduPlane/Log.cpp:363:41: error: 'log_ATRP' is not a member of 'AP_AutoTune'
SCB-WAF: ../../ArduPlane/Log.cpp:363:41: error: 'log_ATRP' is not a member of 'AP_AutoTune'  363 |     { LOG_ATRP_MSG, sizeof(AP_AutoTune::log_ATRP),
SCB-WAF:   363 |     { LOG_ATRP_MSG, sizeof(AP_AutoTune::log_ATRP),      |                                         ^~~~~~~~
SCB-WAF:       |                                         ^~~~~~~~compilation terminated due to -Wfatal-errors.

... I discovered that but only half-undid the change :-(

I really think we should look at changing this to a WriteStreaming or similar...

@@ -1,6 +1,5 @@
#pragma once

#include <AP_Logger/AP_Logger.h>
Copy link
Contributor

Choose a reason for hiding this comment

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

can remove logstructure.h here too, if you remove log_ATRP

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, can't do that as that message is included in ArduPlane's LogStructure!

Should probably be a WriteStreaming call instead, but for now I've put it back in the header, where we only need AP_Logger/LogStructure.h, not AP_Logger.h, which is the important change.

this pulls in many more headers, we should avoid using it whereever we can
this pulls in many more headers, we should avoid using it whereever we can
@peterbarker
Copy link
Contributor Author

Still no compiler output changes with this.

@peterbarker peterbarker merged commit 90af304 into ArduPilot:master Sep 3, 2024
93 checks passed
@peterbarker peterbarker deleted the pr/logger-header branch September 4, 2024 00:40
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