Skip to content

Delay save settings to prevent ESC lockup on emergency rearm#9681

Merged
DzikuVx merged 3 commits intorelease_7.1.0from
MrD_Delay-save-settings-to-prevent-ESC-lockup-on-emergency-rearm
Feb 2, 2024
Merged

Delay save settings to prevent ESC lockup on emergency rearm#9681
DzikuVx merged 3 commits intorelease_7.1.0from
MrD_Delay-save-settings-to-prevent-ESC-lockup-on-emergency-rearm

Conversation

@MrD-RC
Copy link
Member

@MrD-RC MrD-RC commented Jan 30, 2024

The PR pauses the save after disarm if an emergency rearm is possible. This is to stop things like the RX pausing and the ESC restarting if you disarm in flight. If you are still flying, you will have 5 seconds to rearm. After that, the save will happen. The save will not happen if you rearm within the 5 seconds. If you're on the ground. The emergency rearm system will deactivate quickly. So the save will happen soon after landing. OSD messages are shown to show the state of the save process.

Fixes #9441

The PR pauses the save after disarm if an emergency rearm is possible. This is to stop things like the RX pausing and the ESC restarting if you disarm in flight. If you are still flying, you will have 5 seconds to rearm. After that, the save will happen. The save will not happen if you rearm within the 5 seconds. If you're on the ground. The emergency rearm system will deactivate quickly. So the save will happen soon after landing. OSD messages are shown to show the state of the save process.
@MrD-RC MrD-RC added this to the 7.1 milestone Jan 30, 2024
Updated comment on processDelayedSave() delay
@Jetrell
Copy link

Jetrell commented Jan 31, 2024

@MrD-RC Tested it with a quad, having the STATS enabled.. And it worked as you described.

I also ran some back to back tests with the current firmware and this commit. And could replicate @rts18 findings with the current firmware. And found as he did, that having a higher data logging rate caused an increased prevalence of this occurring.
And noticing that it didn't happen every time the FC was disarmed, likely indicates the scheduler was being pushed as the eeprom saving was taking place at disarming, when ESC reboot did happen. And at those times the Saved OSD message would occur at the instant of disarm and emergency rearm.

But when I tested it with this commit. It always delayed the eeprom save until after the emergency rearm window had expired.. And only then would the ESC occasionally reboot, when the Saved message was displayed... But by that time it was on the ground after being auto disarmed. Which is the desired effect.

@breadoven
Copy link
Collaborator

breadoven commented Jan 31, 2024

I'm surprised it appeared to work @Jetrell because it shouldn't as far as I can see simply because the IN_FLIGHT_EMERG_REARM flag can only be set AFTER rearming within the 5s timeout period. It isn't set when you disarm so can't be used to indicate you're within the 5s timeout period ... or maybe I'm missing something ?

@Jetrell
Copy link

Jetrell commented Jan 31, 2024

@breadoven Well.. It did take some getting it to show up in the first place.. This was done by disarming and rearming a good half dozen times, one after another in flight.. And it only rebooted the ESC's once.
While in the test with this commit.. I ran the same cycling maybe 18 times.. And I never seen it happen once.

the IN_FLIGHT_EMERG_REARM flag can only be set AFTER rearming

I guess it was because of the continual disarming and rearming, one after another. Meaning the flag condition was meet.. Either that, or I just got lucky and it didn't happen again.. And I worn out my arming switch for nothing. :-)

@MrD-RC
Copy link
Member Author

MrD-RC commented Jan 31, 2024

When I looked through the code. It appeared that the IN_FLIGHT_EMERG_REARM status is set on disarm, when the function is called to check if emergency rearm is allowed. Then the IN_FLIGHT_EMERG_REARM status is removed 1 second after arming. That would be ideal. But I could check the function directly.

[edit] I was wrong about the above.

I did test with HITL this morning, and noticed that it wasn’t working as expected. There were system messages issues, which I’m working on fixing. I also saw ** SETTINGS SAVED ** when I shouldn’t have. So there is still some work needed.

@MrD-RC
Copy link
Member Author

MrD-RC commented Jan 31, 2024

Now tested in HITL and working as expected.

In flight, if you re-arm within 5 seconds, the settings are not saved. After the 5 seconds expire, the settings are saved. Once landed, disarming by switch or detection saves the settings after a brief pause.

https://youtu.be/5fSwQVvQkg4

@MrD-RC MrD-RC marked this pull request as ready for review January 31, 2024 20:14
@MrD-RC MrD-RC requested a review from breadoven January 31, 2024 20:15
@DzikuVx DzikuVx merged commit 3db6c52 into release_7.1.0 Feb 2, 2024
@DzikuVx DzikuVx deleted the MrD_Delay-save-settings-to-prevent-ESC-lockup-on-emergency-rearm branch February 2, 2024 09:30
@breadoven
Copy link
Collaborator

One issue with this is the IN_FLIGHT_EMERG_REARM flag always gets set on disarming in flight and will remain set when you rearm even after the 5s emergency rearming timeout period expires. Not really a big issue but it does negate the 5s rearm time window in regard to the Home Position and Home Altitude reset override. Bypassing arming checks will still be restricted to the 5s time window however so this isn't an problem at least.

Simple fix for this would be to disable the IN_FLIGHT_EMERG_REARM flag at the start of the emergInflightRearmEnabled function so it always has to be re-evaluated every time the function is called.

@MrD-RC
Copy link
Member Author

MrD-RC commented Feb 2, 2024

@breadoven sounds good to me. I can add this if you like. I was going to add system messages with a countdown for emergency rearm.

[EDIT]
Added to #9688

@MrD-RC
Copy link
Member Author

MrD-RC commented Feb 4, 2024

As a note. The above suggestion was removed from #9688 as it caused issues. However, the home position and altitude are not reset. Looking at the code, it shouldn't reset either while IN_FLIGHT_EMERG_REARM is enabled. It seems fine in HITL.

@MrD-RC
Copy link
Member Author

MrD-RC commented Feb 10, 2024

I think the branch should be restored and this change reverted.

There is something strange going on. I won't have time to get this sorted before the 14th deadline.

@MrD-RC MrD-RC restored the MrD_Delay-save-settings-to-prevent-ESC-lockup-on-emergency-rearm branch February 11, 2024 08:51
@MrD-RC
Copy link
Member Author

MrD-RC commented Feb 11, 2024

I have reverted the changes made by this PR (#9715). I will combine the changes still needed from this PR in to #9688 and continue working there.

@MrD-RC MrD-RC removed this from the 7.1 milestone Feb 11, 2024
MrD-RC added a commit that referenced this pull request Feb 11, 2024
@MrD-RC MrD-RC deleted the MrD_Delay-save-settings-to-prevent-ESC-lockup-on-emergency-rearm branch February 11, 2024 10:00
@MrD-RC MrD-RC added this to the 7.1 milestone Nov 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants