Hi team,
I am relatively new to micropython and am struggling a bit trying to do the following. I have a series of functions implemented in C, which look like:
Code: Select all
void foo(double [] arg1, double [] arg2, double [] arg3)
I would like to create a micropython module that allows me to call such c function from the main .py that is running on an ESP32-based platform. So far, I have created such modules, including methods that allow calling such c functions. For example:
Code: Select all
STATIC mp_obj_t mymod_foo(size_t n_args, const mp_obj_t *args) {
mp_obj_t *arg1, *arg2, *arg3;
mp_uint_t len_arg1, len_arg1, len_arg3;
/* ToDo*/
return mp_const_none;
}
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mymod_obj, 4, 4, mymod_foo);
What I don't know is how to get double-type objects such that I can call the C-function foo(arg1, arg2, arg3). So far, I have tried things like:
Code: Select all
mp_obj_list_get(args[1], &len_arg1, &arg1);
which as expected copies whichever input list I have in args[1] in arg1 as well as extracts the length of such list. Nonetheless, what could I do next? How could I convert arg1 into a double-type array? Or is any other approach to do this?
Regards,
Hinay