Help interfacing with C function and input parameters format

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Keja
Posts: 12
Joined: Sat Dec 19, 2020 9:56 am

Re: Help interfacing with C function and input parameters format

Post by Keja » Fri Apr 23, 2021 4:09 pm

thanks,
it helps a lot.
With your suggestion when I compile I now get :

Code: Select all

GEN build/modrun.config.h
CC modrun.c
LINK build/modrun.o
LinkError: build/modrun.o: undefined symbol: mp_obj_get_array
make: *** [build/modrun.native.mpy] Error 1

my makefile :

Code: Select all

MPY_DIR = ../../..

# Name of module
MOD = modrun

# Source files (.c or .py)
SRC = modrun.c

# Architecture to build for (x86, x64, armv7m, xtensa, xtensawin)
ARCH = armv7emsp
#ARCH = x64


# Include to get the rules for compiling and linking the module
include $(MPY_DIR)/py/dynruntime.mk



# Include to get the rules for compiling and linking the module
include $(MPY_DIR)/py/dynruntime.mk

Thanks for the support

stijn
Posts: 615
Joined: Thu Apr 24, 2014 9:13 am

Re: Help interfacing with C function and input parameters format

Post by stijn » Fri Apr 23, 2021 6:24 pm

dynruntime.h doesn't have mp_obj_get_array so that won't work. Compile a C module instead? Or cast the input argument to an mp_type_list* and access len/items directly (best after checking mp_obj_is_type); don't have experience with the dynamic runtime so not sure if that is the correct way.

Keja
Posts: 12
Joined: Sat Dec 19, 2020 9:56 am

Re: Help interfacing with C function and input parameters format

Post by Keja » Fri Apr 23, 2021 7:24 pm

I ended up compiling a C module instead and it works :)
thank you , your help is much appreciated

Keja
Posts: 12
Joined: Sat Dec 19, 2020 9:56 am

Re: Help interfacing with C function and input parameters format

Post by Keja » Sat Apr 24, 2021 8:14 am

just for information PR#7154 adds mp_obj_get_array to the dynamic runtime and it now also compiles fine with it.
thanks again for helping

Post Reply