-
Notifications
You must be signed in to change notification settings - Fork 1
Add representation for the DaliFrame class. #12
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
base: main
Are you sure you want to change the base?
Conversation
Display the essential data to support inspection of a frame object.
🦙 MegaLinter status: ✅ SUCCESS
See detailed report in MegaLinter reports You could have the same capabilities but better runtime performances if you use a MegaLinter flavor:
|
| if self.priority != 0: | ||
| data = data + f" priority: {self.priority}>" | ||
| return data |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(cleanup)
| if self.priority != 0: | |
| data = data + f" priority: {self.priority}>" | |
| return data | |
| if self.priority != 0: | |
| data = data + f" priority: {self.priority}" | |
| return data + ">" |
However:
(personal preference) If I saw a repr without the priority, I'd assume it having the default priority. This is not the case, because default priority is 2. But I can also see why people may assume unstated = zero. I would nib this ambiguity in the bud by always stating the priority.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually another rabbit hole opens up. priority makes only sense when a frame is send. At the moment, for received frames the priority is untouched and it will be the default value for sending frames.
I would only print out legal priorities, within [2,5] that is. And, in a second step make another PR where I ensure that priority is None for received frames.
|
|
||
| def __repr__(self): | ||
| if self.status != DaliStatus.OK: | ||
| return f"<DaliFrame {self.status}>" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(FWIW) Maybe this should also include the message. But I'm unsure what the "message" is used for.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The serial interface provides additional information about erroneous frames. This is put into the message string. Such a message can be: "ERROR TIMING: START - BIT: 4 - TIME: 1356 USEC". I agree it makes sense to print this information here.
For error-free frames there should be no useful message-contents.
| elif self.length == 32: | ||
| data = data + f"0x{self.data:08X}" | ||
| else: | ||
| data = data + f"0x{self.data:08X} (unknown length)" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(personal preference)
| data = data + f"0x{self.data:08X} (unknown length)" | |
| data = data + f"0x{self.data:X} (unknown length)" |
Display the essential data to support inspection of a
DaliFrameobject.