Conversation
|
@falkoschindler I moved the error handling to its own pull request |
falkoschindler
left a comment
There was a problem hiding this comment.
I have some questions and doubts about the current concept:
- Are error codes meant to be binary flags that can be added to get combined errors like, e.g., 5 = 1 (low voltage) + 4 (no response from motor driver)? If so,
set_errorwould overwrite existing errors when setting another one. - Currently,
set_errorcan be called withERROR_NONE, which results in a wrong value forhas_error_. It looks like theErrorHandlingAPI would need additional methods likeadd_error,remove_errorandclear_errorsto cover all cases. But then it might be easier to just expose theerror_codesmap directly. - Is it a good idea to share a common list of error codes across all modules? I can imagine conflicts when a module needs an error similar but not identical to one from another module. We would either need to introduce many error codes with similar names and meanings, or pricisely document error codes per module. If so, I don't see the point in a common list of error codes.
Maybe the current implementation with only two errors in a single module is too early to see the big picture. But at the moment I lean towards a new "error" property in the expander module with two additive codes (connection timeout and connection loss). This way it can be accessed like any other property, used in rules, and added to the core output line.
If we really want a global error property or method in the core module, we can iterate over modules and aggregate errors. But right now there is no benefit.
|
Branch is restored and diff should be correct now. |
I thought about it, and using a bit mask could solve this. Each error would be a single bit, allowing multiple errors to be combined without overwriting.
With a bit mask, ERROR_NONE is unnecessary, since a value of 0 naturally represents no errors. However, I think we would still need these API methods (
I think some error codes could be in all modules ( |
[Update] Merge main into branch
|
This looks good so far. I will verify it to work with #125 once it is merged with main. |
update branch with main changes
|
This is somewhat what I imagine for error codes. Yet, there is a bug in this somewhere with flashing the expander. |
This is a possible implementation of error codes on the expander module.