So i try to load a script i wrote to a cortext M4 chip. The basic print and all are working, however, i cant get my add-on module to work due to no system file on the chip (using crossworks). i cant load the file using file name. Is there a way to do this.
Here the code that i have:
Code: Select all
//load and compile python src file
void compile_pyfile(const char* fileName)
{
mp_lexer_t *lex = mp_lexer_new_from_file(fileName);
mp_parse_tree_t pt = mp_parse(lex, MP_PARSE_FILE_INPUT);
mp_obj_t module_fun = mp_compile(&pt, lex->source_name, MP_EMIT_OPT_NONE, false);
mp_call_function_0(module_fun);
}
Code: Select all
do_str():
[..]
mp_lexer_t *lex = mp_lexer_new_from_str_len(MP_QSTR__lt_stdin_gt_, src, strlen(src), 0);
qstr source_name = lex->source_name;
mp_parse_tree_t parse_tree = mp_parse(lex, input_kind);
mp_obj_t module_fun = mp_compile(&parse_tree, source_name, MP_EMIT_OPT_NONE, true);
mp_call_function_0(module_fun);
Code: Select all
import TestModule;
def helloC():
print('Call hello function from C')
TestModule.hello()
TestModule.hello_XYZ('XYZ')
Thanks in advance