-
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_Relay: Refactor to support RELAYx_FUNCTION #25108
AP_Relay: Refactor to support RELAYx_FUNCTION #25108
Conversation
d9dcc3e
to
61d041c
Compare
5c6479b
to
0547b5c
Compare
// @User: Standard | ||
AP_GROUPINFO("PIN", 2, AP_Relay_Params, pin, -1), | ||
|
||
// @Param: DEFAULT |
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.
what is the state during boot period for a pin that will become a relay output?
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.
It's defined by the hwdef (both bootloader and normal firmware) + any hardware level pullups. This is the same as it always has been, and there is no provision to let you control the pins from the bootloader.
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 think we should try to remove the update() call, and do the logging at the time the set or toggle, to avoid excessive logging we will need a hal.gpio read first so we only log when the value actually changes
also removing _pin_states will avoid race conditions
0547b5c
to
34acc89
Compare
Done. Generally it's more readable (although with comments it didn't end up shorter). The only thing I'm aware of is that when you start logging you might not get any indication of where a relay was before you started. And sending out the MAVLink message requires scanning all the pins. |
5fbc296
to
3bc4b5f
Compare
3bc4b5f
to
2611cea
Compare
2611cea
to
c10c653
Compare
@WickedShell we can't really do anything on the dev call with it failing the relay CI tests. Did you want someone else to work on it? |
looking forward to this restructure. |
c10c653
to
4f930ea
Compare
4f930ea
to
03b0b2b
Compare
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 fine, really.
Has the Rover change been tested in SITL?
} else { | ||
ap_relay->on(0); | ||
} | ||
ap_relay->set(AP_Relay_Params::FUNCTION::CAMERA, !_params.relay_on); |
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.
This pattern precludes us having two relay cameras, it seems. You might be in the second camera backend here.
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.
Your right, but this is the current behavior. We certainly could add a second camera relay function in the future.
03b0b2b
to
cc03050
Compare
Yes, tested param conversion and arming check in SITL. I have not tested the actual relay outputs, but CI covers lots of the other functions. |
cc03050
to
ce2f4ff
Compare
This refactors the AP_Relay library as proposed on the dev call yesterday.
Things that stand out from the refactoring:
Downsides:
Things missing as currently presented:
RELAY_X_FUNCTION
and the like. That's straightforward.I haven't done the work to do parameter conversion yet, I wanted to present a prototype that is working with a CubeOrangePlus on the bench, with a oscilloscope hooked up to the outputs. Pin states were toggled using both the
relay
andengine
commands inMAVProxy
.