Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Discussion options

You must be logged in to vote

I would expect that buf would be passed in the same way that Micropython passes integers. So in your C code you will have to extract the integer and cast it to a pointer first. The way to do this is using the macros in py/obj.h:

#include "py/runtime.h"

static mp_obj_t perform_test(mp_obj_t buf_obj) {
    uint8_t *buf = (uint8_t*)(mp_obj_get_uint(buf_obj);
    buf[0] = 1;
    return mp_const_none;
}

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
2 replies
@GanerCodes
Comment options

@GanerCodes
Comment options

Answer selected by GanerCodes
Comment options

You must be logged in to vote
1 reply
@GanerCodes
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants