Skip to content

Commit

Permalink
pybricks.tools.AppData: Default to empty receive format.
Browse files Browse the repository at this point in the history
Sometimes the class is just used for outgoing data, so receiving should
be optional.
  • Loading branch information
laurensvalk committed Aug 22, 2024
1 parent cf12eea commit ef9f7fd
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pybricks/tools/pb_type_app_data.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,12 @@ STATIC mp_obj_t pb_type_app_data_write_bytes(mp_obj_t self_in, mp_obj_t data_in)
}
STATIC MP_DEFINE_CONST_FUN_OBJ_2(pb_type_app_data_write_bytes_obj, pb_type_app_data_write_bytes);

static const mp_obj_str_t pb_const_empty_str_obj = {{&mp_type_str}, 0, 0, (const byte *)""};

STATIC mp_obj_t pb_type_app_data_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {

PB_PARSE_ARGS_CLASS(n_args, n_kw, args,
PB_ARG_REQUIRED(rx_format));
PB_ARG_DEFAULT_OBJ(rx_format, pb_const_empty_str_obj));

// Use ustruct.calcsize to parse user rx_format for size.
mp_obj_t ustruct_calcsize = pb_function_import_helper(MP_QSTR_ustruct, MP_QSTR_calcsize);
Expand Down

0 comments on commit ef9f7fd

Please sign in to comment.