Here's relevant code so far
Code: Select all
STATIC const mp_rom_map_elem_t can_message_type_locals_dict_table[] =
{
{MP_ROM_QSTR(MP_QSTR_msg_id), MP_ROM_PTR(&mp_type_int)},
{MP_ROM_QSTR(MP_QSTR_msg_data), MP_ROM_PTR(&mp_type_list)},
};
STATIC MP_DEFINE_CONST_DICT(can_message_type_locals_dict, can_message_type_locals_dict_table);
const mp_obj_type_t can_message_type =
{
{&mp_type_type},
.name = MP_QSTR_message,
.print = can_message_obj_print,
.make_new = can_message_make_new,
.locals_dict = (mp_obj_t)&can_message_type_locals_dict
};
Python
Code: Select all
msg = can_message()
msg.msg_id = 55
msg.msg_data = [1, 2, 3, 4, 6]
Python
Code: Select all
msg.bajsdlsakdfa = 55
...
As I was writing this I think I know the answer: I need to create a mp_type_can_message.attr function and inside it, check if the "qstr attr" argument exists.
If there's a better way, please reply.