py_sensor.c code question

Discussion related to "under the hood" OpenMV topics.
User avatar
wminarik
Posts: 5
Joined: Tue Aug 02, 2016 2:33 pm

py_sensor.c code question

Postby wminarik » Fri Aug 26, 2016 4:22 pm

In py_sensor.c, there is a routine that is part of the initialization: py_sensor_skip_frames()

It starts off:

Code: Select all

static mp_obj_t py_sensor_skip_frames(uint n_args, const mp_obj_t *args) {
int frames = (n_args == 1) ? mp_obj_get_int(args[0]) : 10; // OV Recommended.
I'm confused by this code -I'd submit a github pull request, but I'm afraid that I'm missing something obvious:

Isn't n_args always at least equal to '1' , and args[0] contains the name of the routine? If so, then mp_obj_get_int(args[0]) always fails.
Should this code instead be:

Code: Select all

int frames = (n_args > 1) ? mp_obj_get_int(args[1]) : 10; // OV Recommended.
Cheers,
Bill
User avatar
kwagyeman
Posts: 4458
Joined: Sun May 24, 2015 2:10 pm

Re: py_sensor.c code question

Postby kwagyeman » Fri Aug 26, 2016 4:56 pm

Args[0] isn't the name of the routine. It's the first argument.

Look at the code that calls these things. It's buried somewhere in the MP py dir. The calling code uses slightly different call patterns given the situation.
Nyamekye,

Return to “Technical Discussion”

Who is online

Users browsing this forum: No registered users and 1 guest