Hello,
I am porting micropython to some HW...
How do I raise a kbd exception when the use presses on the "stop" key?
I know that I need to enable MICROPY_KBD_EXCEPTION, but I am missing the last part of the link to actually generate the exception.
Thanks,
Cyrille
how to raise a keyboard exception
Re: how to raise a keyboard exception
In you C code, call:
mp_keyboard_interrupt();
mp_keyboard_interrupt();
Re: how to raise a keyboard exception
Hello,
I tried it, but unfortunately, it seems that mp_keyboard_interrupt is not defined anywhere...
enabeling
#define MICROPY_KBD_EXCEPTION (1)
and adding a call to mp_keyboard_interrupt
Generates 2 link errors:
3>skin.obj : error LNK2001: unresolved external symbol _mp_keyboard_interrupt
3>modmicropython.obj : error LNK2019: unresolved external symbol _mp_hal_set_interrupt_char referenced in function _mp_pystack_usage
3>P:\trv\fir_trunk\FIR\_qt5\Debug\Win32\\HPPrime.exe : fatal error LNK1120: 2 unresolved externals
Any clue as to what might be wrong?
EDIT:
looking on the net, I found an implementation for mp_keyboard_interrupt:
void mp_keyboard_interrupt()
{
MP_STATE_VM(mp_pending_exception) = (MP_STATE_PORT(mp_kbd_exception));
}
Unfortunately, that did not compile...
Hard casting like this did...
void mp_keyboard_interrupt()
{
MP_STATE_VM(mp_pending_exception) = (mp_obj_t*)&(MP_STATE_PORT(mp_kbd_exception));
}
So that is what I ended up doing.
Thanks,
Cyrille
I tried it, but unfortunately, it seems that mp_keyboard_interrupt is not defined anywhere...
enabeling
#define MICROPY_KBD_EXCEPTION (1)
and adding a call to mp_keyboard_interrupt
Generates 2 link errors:
3>skin.obj : error LNK2001: unresolved external symbol _mp_keyboard_interrupt
3>modmicropython.obj : error LNK2019: unresolved external symbol _mp_hal_set_interrupt_char referenced in function _mp_pystack_usage
3>P:\trv\fir_trunk\FIR\_qt5\Debug\Win32\\HPPrime.exe : fatal error LNK1120: 2 unresolved externals
Any clue as to what might be wrong?
EDIT:
looking on the net, I found an implementation for mp_keyboard_interrupt:
void mp_keyboard_interrupt()
{
MP_STATE_VM(mp_pending_exception) = (MP_STATE_PORT(mp_kbd_exception));
}
Unfortunately, that did not compile...
Hard casting like this did...
void mp_keyboard_interrupt()
{
MP_STATE_VM(mp_pending_exception) = (mp_obj_t*)&(MP_STATE_PORT(mp_kbd_exception));
}
So that is what I ended up doing.
Thanks,
Cyrille