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

Add IMU timeout detection to SoftFusionSensor #376

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

pembem22
Copy link

Adds IMU timeout detection: sends an error and changes status if no data received for more than 2 seconds. Copypasted from ICM20948 code, tested with LSM6DSO.

@pembem22 pembem22 requested a review from gorbit99 as a code owner January 13, 2025 18:02
src/sensors/softfusion/softfusionsensor.h Outdated Show resolved Hide resolved
src/sensors/softfusion/softfusionsensor.h Outdated Show resolved Hide resolved
@pembem22 pembem22 requested a review from Eirenliel as a code owner January 14, 2025 20:06
src/network/packets.h Outdated Show resolved Hide resolved
@gorbit99 gorbit99 self-requested a review January 16, 2025 17:46
Copy link
Contributor

@gorbit99 gorbit99 left a comment

Choose a reason for hiding this comment

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

lgtm

@pembem22 pembem22 requested a review from gorbit99 January 19, 2025 18:03
@pembem22
Copy link
Author

pembem22 commented Jan 19, 2025

I've been getting random timeouts of both sensors at the same time every once in a while, which makes sense considering that millis() overflow in a bit more than one hour. I think the last commit should fix that.

@gorbit99
Copy link
Contributor

Not sure if it fixes it, everything is an uint, so it will wrap around when you subtract. Personally I'd switch to millis instead of micros, that has a wraparound of about 50 days, and it's not like you need the accuracy of micros.

@gorbit99
Copy link
Contributor

Should be good now

@unlogisch04
Copy link
Contributor

unlogisch04 commented Jan 19, 2025

Would it not better to fix that here https://github.com/SlimeVR/SlimeVR-Tracker-ESP/blob/main/src/sensors/softfusion/softfusionsensor.h#L231 ?

edit: nvm. A different case. It may take longer every turnover (~1.1h) to drop 1 sending of data.

Copy link
Contributor

@unlogisch04 unlogisch04 left a comment

Choose a reason for hiding this comment

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

Not sure if it does matter. Else it looks good to me.

@@ -67,4 +67,8 @@
#define PACKET_INSPECTION_DATATYPE_INT 1
#define PACKET_INSPECTION_DATATYPE_FLOAT 2

enum class PacketErrorCode : uint8_t {
Copy link
Contributor

Choose a reason for hiding this comment

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

That seems not to be defined till now. On BNO it sends the following.
https://github.com/SlimeVR/SlimeVR-Tracker-ESP/blob/main/src/sensors/bno080sensor.cpp#L220-L223
//Get the reason for the last reset
//1 = POR, 2 = Internal reset, 3 = Watchdog, 4 = External reset, 5 = Other

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