Refactor the response parsing. Fixes an "increase volume" bug. Also minor comments and code cleanups.#31
Open
Plan-V64 wants to merge 5 commits intobasnijholt:mainfrom
Open
Refactor the response parsing. Fixes an "increase volume" bug. Also minor comments and code cleanups.#31Plan-V64 wants to merge 5 commits intobasnijholt:mainfrom
Plan-V64 wants to merge 5 commits intobasnijholt:mainfrom
Conversation
added 3 commits
August 31, 2023 12:52
The prior code broke in the case where a response happened to contain a payload byte equal to _RESPONSE_START. For example, when getting the speaker volume which happens to be at 82%. This refactoring also contains a minor API cleanup: it always returns the full message, including the leading 0x52 byte. The old code was not consistent on that point. This API change does not matter for the existing callers.
(Remove mixed use of the word "reply".)
228e7ae to
cf3206d
Compare
Owner
|
Thanks a lot! Unfortunately, both my LS50Ws and LSXs broke ... so I do not have reliable means to test this. Have you successfully run this code with real hardware? If so, I will just click merge because the code seems solid 😄 |
Owner
|
I do not understand why the CI is not starting here 😅 |
Author
That is very disappointing! All the more so after you put in so much work to support them.
Yes, on the KEF LSX. (The original, not the LSX II.) Caveats: I have:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When calling aiokef.AsyncKefSpeaker.increase_volume() when my speaker was at volume level 82%, aiokef did not parse the speaker's response data correctly, and thought that the volume level was 37%.
This caused aiokef to set the volume to 42% instead of the intended 87%.
The culprit is the .split(b"R") operation on the received data in _parse_response().
Heads-up: The refactored code introduces an assumption that the size of all responses that aiokef will currently encounter is 3 or 5 bytes. Please verify that you agree that that is a reasonable assumption for the current use cases of aiokef, before merging this commit.
Heads-up: The code cleanup includes a minor change of the API of _parse_response(). It now always returns the full message (including the leading "R" byte).