SF45 fixes to restart the state machine if sensor does not init correctly #23565
+88
−13
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #23308 when the SF45 is on specific UARTS, the sensor never reports distance data due to being stuck in init.
Also populates comms_errs if there are issues reading/writing data.
The serial uart data being read reports the start of packet invalid, payload length invalid, and CRC mismatch in the early sensor init state, so the SF_STREAM command never gets sent out. This PR restarts the state machine if there are too many consecutive errors in the beginning that are the result of UART data mismatch on what the driver expects and what the sensor sends. For unknown reasons the sensor seems to work much better on TELEM1 and TELEM2
Tested on holybro 6x where TELEM 1 and TELEM2 worked fine with the original driver, but TELEM3 did not and the start of packet invalids caused the sensor to never stream distance data. With this fix the driver actually reports distance data on telem 3.