-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding mymodule.c error #3
Comments
I am getting this same error. Have you found a solution to it yet? |
I managed to make it work in the end but I would have to search for the code. I had to switch to C in the end. For sure you have to remove the ".name" field because the documentation is outdated and they removed this field in the meantime. If this does not help you, let me know, I will search my code. |
Thanks. I removed the ".name" field and got it to compile and import the module. If you dont mind, Im having trouble actually calling the function defined here in micropython. After I import mymodule.c would calling the hello world function be mymodule.mymodule_hello() ? MicroPython v1.9.1-185-gaa7be82-dirty on 2017-08-03; linux version
|
How to call the function depends on how you import your module. Best way is to open the REPL, import your module and check which function calls it offers you after hitting tab. I can not remember anymore but I think I moved from writing modules in C to directly write helper functions in C because the documentation on writing modules for micropython was quite limited. I think I figrued that out while trying to import arrays into my module. |
Yes the .name-property was outdated, the documentation here is updated now. The important piece of code is here: STATIC const mp_map_elem_t mymodule_globals_table[] = {
{ MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_OBJ_NEW_QSTR(MP_QSTR_mymodule) },
{ MP_OBJ_NEW_QSTR(MP_QSTR_hello), (mp_obj_t)&mymodule_hello_obj },
}; The global names of your module consists of a string The interesting thing here, is that the Python interpreter basically knows only the strings you let him know. It will not know any of the C-function names or variables you declare in your C-files. These names are there for the C-compiler and once you link it all together for the firmware.img-file, these labels are gone. So the proper way to call your function would be: import mymodule
mymodule.hello(); Python knows the |
Hi, |
I think you will have the best chance for help if you ask this on the micropython forum. |
Following the instructions of how to add a module I do get the following error.
The text was updated successfully, but these errors were encountered: