hal: Update halmodule to getter/setter and the query API - #4317
Merged
Conversation
grandixximo
reviewed
Aug 2, 2026
BsAtHome
force-pushed
the
halgs_halmodule
branch
from
August 2, 2026 09:45
83960b4 to
18e821e
Compare
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 moves the current halmodule to getter/setter and uses only the HAL query API.
We cannot move to a new C++ halmodule implementation before everything is in place. We need to retain the infrastructure so we can move forward.
The new port pin creation is enabled (hal_pin_new_port()) using a slightly different signature than what it will become. This is done for compatibility sake because the hal_port_t is already in use and can only be fixed when we break the API. So that will have to wait. In the meantime, we use an intermediate.
Halmodule no longer accesses hal_priv.h. Quite some lines could be removed by using the query API. Also, the new API is much simpler for the halitem and removes the old pin/param/type/direction union stuff.
It is no longer required to create a component before accessing the generic pin/signal access methods. Halmodule will call
hal_lib_init()when imported and register aPy_AtExit(hal_lib_exit)to remove the share memory. This also makes the check in hal_lib effective when components are left dangling. At exit it will specify which components were never exited.You can now do
hal.get_value('some.pin.name')immediately after importing the module. The same goes forset_p/set_s. Also, functionsget_p/get_sare added. The get_value would test pins/params/signals, whereas other utilities have a split. This is now possible. An added check tests this and also uses the threadbeat for cycle advancement testing (also has a timeout, but that is to guard infinity).