Commit 0b14c45
mcdax
fix(BeltState.PAUSED): two regressions where pause didn't land at PAUSED
Both surfaced via tests/stress_dynamic.py (pause_resume scenario + a
random walk that reconnected mid-session). Each could mis-derive
belt_state as STOPPED instead of PAUSED:
1) `_paused` deceleration race in `_on_treadmill_data`.
The previous version cleared `_paused` on every Treadmill Data
frame with speed > 0. Pause sets the flag at speed ≈ 2.5; the
~5–10 s deceleration to zero produces dozens of speed > 0 frames,
each clearing the flag, so by the time speed reached 0 the
`_paused` branch was dead and belt_state derived as STOPPED.
`_paused` is now set/cleared exclusively by `_on_machine_status`
in response to FM Status events (STOPPED_OR_PAUSED+PAUSE,
STOPPED_OR_PAUSED+STOP, STARTED_OR_RESUMED, safety-stop, and on
disconnect). The Treadmill Data path only reads it.
2) "First 2ADA event after subscribe" filter dropped real ack state.
The defensive filter that drops the first 2ADA event after CCCD
subscribe was added because the firmware replays its prior state
when notifications are enabled (so `last_fm_event` would flap on
every reconnect). But when the user's first command after a fresh
connect produces an ack as the first event — e.g. pause() right
after reconnect → FM Status PAUSE — the filter ate it as if
stale, the ack waiter got woken but _paused was never set, and
belt_state ended at STOPPED.
Heuristic: if the first event matches `_status_ack_expected_opcode`,
treat it as the real ack and fall through to the normal handler.
Otherwise (unexpected opcode, no command pending) skip as before.1 parent 03472dd commit 0b14c45
2 files changed
Lines changed: 40 additions & 17 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
410 | 410 | | |
411 | 411 | | |
412 | 412 | | |
413 | | - | |
414 | | - | |
| 413 | + | |
415 | 414 | | |
416 | 415 | | |
417 | | - | |
418 | | - | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
419 | 425 | | |
420 | 426 | | |
421 | | - | |
422 | 427 | | |
423 | 428 | | |
424 | 429 | | |
| |||
525 | 530 | | |
526 | 531 | | |
527 | 532 | | |
528 | | - | |
529 | | - | |
530 | | - | |
531 | | - | |
532 | | - | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
533 | 549 | | |
534 | 550 | | |
535 | | - | |
536 | | - | |
537 | | - | |
538 | | - | |
539 | 551 | | |
540 | 552 | | |
541 | 553 | | |
542 | 554 | | |
543 | | - | |
544 | | - | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
545 | 568 | | |
546 | 569 | | |
547 | 570 | | |
| |||
0 commit comments