bristlemouth / bm_protocol

Primary Bristlemouth firmware repository
https://www.bristlemouth.org/
Apache License 2.0
12 stars 8 forks source link

fix: subsampling #130

Closed towynlin closed 6 months ago

towynlin commented 6 months ago

[sc-201530]

This fixes a bug in the bridge power controller's subsampling behavior, often used with RBR sensors. Prior to this change, if subsampling was enabled, and if the end of the sample duration fell between the end of the last subsample duration and the start of the next aligned sample interval, then the start of the next sample interval would actually again leave the bus off to align to the next sample interval.

I added some unit tests involving a couple different cases of subsampling.

The fix is essentially to avoid sleeping across that end-of-sample-duration boundary, allowing the power controller to wake up and align the next sample before it starts.