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

Remove phantom pedal strokes. #35

Closed
wants to merge 1 commit into from
Closed

Conversation

jeremydk
Copy link
Contributor

If the last cadence received by gymnasticon is non-zero, we continue to fire off phantom pedal strokes (which continuously reset the pingInterval). We can remove the pingInterval resetter from onPedalStroke, and force the cadence to zero if we receive a ping request (i.e. no stats received in the last second).

I've tested this from my Peloton and all looks good, but would need to have someone validate the flywheel behavior.

This should address #32

If the last cadence received by gymnasticon is non-zero, we continue to fire off phantom pedal strokes (which continuously reset the pingInterval).  We can remove the pingInterval resetter from onPedalStroke, and force the cadence to zero if we receive a ping request (i.e. no stats received in the last second).

I've tested this from my Peloton and all looks good, but would need to have someone validate the flywheel behavior.
@ptx2
Copy link
Owner

ptx2 commented Feb 1, 2021

Just gave it a try on the Flywheel bike. I did notice something that might need a look into. It seems possible to get in a situation where we stop generating pedal strokes depending on the timing of ping interval and stats events.

It's possible to reproduce with the bot like this:

gymnasticon --bike bot --bot-power 60 --bot-cadence 50 --bot-host 127.0.0.1 --bot-port 3000

I think the issue is with setting simulation.cadence to 0 periodically.

I realized there is actually a timer in there to handle this already but I made a typo so it's not actually firing ;-) If you rename opts.bikeStatsTimeout to opts.bikeReceiveTimeout in the statsTimeout Timer initialization, it will bail shortly after the bike stops sending data, the idea being that systemd will restart it. I pushed up a change which uses that timer to fix the immediate problem but there's an unsolved problem I'm running into where if you exit a ride and re-enter, Zwift appears to require you to manually rechoose the power/cadence sensors before they'll work again. Out of time for today but I pushed up what I have so far here: https://github.com/ptx2/gymnasticon/compare/peloton-stats-timeout

@ptx2
Copy link
Owner

ptx2 commented Feb 1, 2021

Ok I just reverted those changes and pushed up something different to that same branch. It just sends the app a single zero stats event after the user has left the ride. I've tested it a bit here and looks good -- what do you think?

@jeremydk
Copy link
Contributor Author

jeremydk commented Feb 1, 2021

That proposed change makes sense to me -- scopes us just to the peloton, and uses the fact that the serial connection is very chatty, so a 1s timeout makes a lot more sense. Wasn't a fan of letting systemD flap the service -- it would work but it felt a bit off to me.

@ptx2
Copy link
Owner

ptx2 commented Feb 2, 2021

I wasn't a huge fan either :-) I'll go ahead and merge that in. Thanks for the help finding and fixing this!

@ptx2 ptx2 closed this Feb 2, 2021
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.

2 participants