Open
Conversation
Collaborator
Author
|
@nierob might find this amusing |
Just the very basic infrastructure to make debugging easier. Since most people have only one receiver, we need to be able to capture logs. One option for users is to simply uncomment one line to enable logging of all communication through serial or telnet.
nierob
reviewed
Apr 29, 2020
Comment on lines
+185
to
+186
| if attr.startswith("_"): | ||
| return |
There was a problem hiding this comment.
Why that? Shouldn't that raise AttributeError? (https://docs.python.org/3/reference/datamodel.html#object.__getattr__)
| return _CallHandler(self._transport, self._domain, attr) | ||
| raise TypeError(f"{attr}") | ||
| if self._op: | ||
| raise TypeError(f"{self} has no attribute {attr}") |
This implements the complete RS232 API of the receiver in a mock class. With this the receiver can be tested locally without having any serial port. Add a test that checks that communication with that particular amplifier doesn't break again. Similar tests are needed for other models, but since this is the only amp I have, I'm not easily able to write them. The sources are for now left out because the current implementation assumes sources to be integers, while the V2 protocol is purely string based.
We have a complete description of the protocol in nad_commands. Let's use it. This dynamically generates objects from the command dictionary, so that new functions do not need any code any more. Instead one can simply call: receiver.main.volume.increase() This works by inspecting nad_commands when asking for attributes of the receiver class or it's dynamically created subclasses. The old API is around unchanged to stay compatible.
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.
This is a bit of an exercise to play with Python attributes. See description in the commit message of 4c73c46
Basically new API can be added by just editing CMDS in nad_commands.py.
receiver.main.volume.increase()works then by inspecting the commands dictionary.