-
Notifications
You must be signed in to change notification settings - Fork 17.3k
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_ExternalAHRS: Change the define definition to an enum class #28104
base: master
Are you sure you want to change the base?
AP_ExternalAHRS: Change the define definition to an enum class #28104
Conversation
@muramura Can you check if the binary output is equal as well? |
@amilcarlucas san. AFTER and BEFORE are the same size. AFTER BUILD SUMMARY
|
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.
I'm not in favour of this as it currently stands.
The static casts make it far less readable.
It could be done with something like a has_status
method, but I don't think we need to go there.
I'm going to ping @valentinb on this PR - he's most recently changed this stuff and can either back me up or say he loves it and would love to have it pushed forward.
@@ -84,6 +84,54 @@ class AP_ExternalAHRS_InertialLabs : public AP_ExternalAHRS_backend { | |||
INS_SOLUTION_STATUS = 0x54, | |||
}; | |||
|
|||
// unit status bits | |||
enum class ILABS_UNIT_STATUS : uint16_t { |
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.
enum class ILABS_UNIT_STATUS : uint16_t { | |
enum class UnitStatus : uint16_t { |
similarly elsewhere
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.
I changed the ENUM name.
GCS_SEND_TEXT(MAV_SEVERITY_CRITICAL, "ILAB: Accelerometers failure"); | ||
} | ||
|
||
if (state2.unit_status & ILABS_UNIT_STATUS_MAG_FAIL) { | ||
if (state2.unit_status & static_cast<uint16_t>(ILABS_UNIT_STATUS::MAG_FAIL)) { |
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.
You can't tell me this looks better!
There are ways this could be done to look quite nice, but this is not one of them!
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.
I believe that by using ENUM CLASS, we can detect the bug in #28111 at the coding stage.
c57b8e7
to
e731615
Compare
#28111 fix has been included. |
Hello. A couple of days ago I updated the part with InertialLabs EAHRS handler Thanks for finding and fixing the bug I can't say anything about using "define" or "enum class". |
An alternative approach to a static cast is to add an overload to the unary Advantages:
Disadvantages:
|
The define definition is grouped with a group name.
I will change it to ENUM CLASS.