hal: Add the HAL query API and add IntEnum types - #4382
Open
BsAtHome wants to merge 1 commit into
Open
Conversation
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 PR adds the complete HAL query API to halmodule as a sub-module
hal.query. It also adds IntEnum classes under thehalclass so that pin/param/signal types now can behal.Type.BOOL,hal.Type.REAL,... The same for directionhal.Dir.IN,hal.Dir.RW, etc. The hal.query methods use these in the returned dictionaries too.The
HAL_prefixed names are also in the enums, but the old[HAL_]FLOAT,[HAL_]BIT,[HAL_]S64and[HAL_]S64names were removed from the enumerated type. In the interim, there still are S32/U32 names registered for compatibility. Using the HAL_ prefix is just extra baggage that is not necessary. You should use the plain names without prefix. Note that allhal.HAL_*constants are not changed and still available for compatibility reasons.The hal.query is a sub-module written using pybind11. The same will also happen to halmodule when we get to that point (@rene-dev will be happy). The pybind11 library is now a build dependency and added as such. A configure check has been added.
The
hal.get_realtime_type()method has been updated to return the newhal.RTTypeIntEnum. The old constants are still available, but it is better to move to enums because they are much more informative than a bare number and IntEnum is fully compatible with numeric values.The documentation has been updated and the new APIs added to the adoc. Some formatting has also been done.
There are now, in the docs, notices about deprecation of the old-style constants and the IntEnums should be preferred. Also,
get_info_pins,get_info_paramsandget_info_signalsare marked as deprecated in the doc. These are replaced by the query API.@petterreinholdtsen When this is merged, then #4231 can be updated and use the generic query API.