Page 1 of 1

NameError: name is not defined

Posted: Mon Mar 05, 2018 2:54 am
by mfwebn
boot.py:
[code]
# boot.py -- run on boot-up
print('MicroPython boot')
[/code]

APIs:
[code]
mp_uint_t f_rd_read_byte(void *data){
mp_uint_t r_data;
UINT read_len = 1;
FRESULT res;
res = f_read((FIL *)data, &r_data, 1, &read_len);
if(res != FR_OK || read_len == 0 || r_data == (mp_uint_t)EOF){
return MP_READER_EOF;
}
else{
return r_data;
}
}

void f_rd_close(void *data){
f_close((FIL *)data);
m_free(data);
}

void reader_new_file(mp_reader_t *reader,const char *filename)
{
FIL *fp;
.....(open file)
reader->data = (void *)fp;
reader->readbyte = f_rd_read_byte;
reader->close = f_rd_close;
}

mp_lexer_t *mp_lexer_new_from_file(const char *filename)
{
mp_reader_t reader;
reader_new_file(&reader,filename);
return mp_lexer_new(qstr_from_str(filename), reader);
}
[/code]

I use the pyexec_file function to execute boot.py, but I return the error:

exec start
Traceback (most recent call last):
File "boot.py", line 1, in <module>
NameError: name '# boot.py -- run on boot-up
print('MicroPython boot')' is not defined