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

Define UPS_States values as pow of 2 to fix state change detection #71

Merged

Conversation

supersmile2009
Copy link
Contributor

The existing state detection logic relies on bitwise operations to compare old and new state and to extract the changed state flags. However it's fundamentally broken due to UPS_States enum not using the power of 2 values. Bitwise logic produces invalid states change set because of that.

I discovered it while I was trying to make this client follow FSD signal from the server. But it never detects the change for FSD state. The only case when it starts the shutdown procedure is if you connect to the server which is already in FSD state.

@gbakeman
Copy link
Contributor

gbakeman commented Feb 3, 2023

Sorry for taking so long to get to this; usual real life activities so projects had to be put on hold.

I could've sworn enum values were auto-generated in powers of two when using the FlagsAttribute, but sure enough, they need to be manually defined. Thank you so much for this, I'm just trying to get my VM with upsd up so I can figure out how I even missed this and then merge your changes.

Thank you for contributing!

@gbakeman gbakeman self-assigned this Feb 3, 2023
@gbakeman gbakeman added the bug Something isn't working label Feb 3, 2023
@gbakeman gbakeman added this to the 2.2 Stable Release milestone Feb 3, 2023
@gbakeman gbakeman merged commit 5c85475 into nutdotnet:Dev-2.2 Feb 5, 2023
@supersmile2009
Copy link
Contributor Author

Hey @gbakeman. You have nothing to be sorry about. It's open source, everyone has different capacity for this kind of work. I'd actually say it was a fairly decent response time considering that you're just a single maintainer here and have other job. Thanks for finding time to take a look at it and merging!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants