getting the value of mp_hal_ticks_ms() in a natmod #17360
Replies: 2 comments 3 replies
-
i'm also wondering how to access any RNG devices exposed in the hal. i suppose the solution would be similar to the timer access? |
Beta Was this translation helpful? Give feedback.
-
All the functions available to native modules are found in py/dynruntime.h and the function table mp_fun_table_t found in py/nativeglue.h - so that basically defines what is possible and not in terms of interacting with the MicroPython runtime. To access time.time(), I believe you should be able to use Another alternative would be to explicitly pass a function from Python that can return the time/tick to your module, and then call that (again with mp_call_function_n_kw). PS: you may want to use time.tick_ms/ticks_us instead of time.time, if you want a integer |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
i need to have access to a timer in a natmod (to mock time(2)) i saw this: https://github.com/orgs/micropython/discussions/11657 - so i'm not sure if this is a viable option, but i believe calling time.time() from python would give access to such a timer. is there a way to call a python module.function from a natmod? haven't seen that in the examples.
Beta Was this translation helpful? Give feedback.
All reactions