Skip to content

Commit f8d42da

Browse files
committed
extmod/modlwip: Add .print() method.
1 parent 3fbbbec commit f8d42da

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

extmod/modlwip.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,12 @@ STATIC mp_uint_t lwip_tcp_receive(lwip_socket_obj_t *socket, byte *buf, mp_uint_
424424

425425
STATIC const mp_obj_type_t lwip_socket_type;
426426

427+
STATIC void lwip_socket_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
428+
lwip_socket_obj_t *self = self_in;
429+
mp_printf(print, "<socket state=%d timeout=%d incoming=%p remaining=%d>", self->state, self->timeout,
430+
self->incoming.pbuf, self->leftover_count);
431+
}
432+
427433
// FIXME: Only supports two arguments at present
428434
STATIC mp_obj_t lwip_socket_make_new(const mp_obj_type_t *type, mp_uint_t n_args,
429435
mp_uint_t n_kw, const mp_obj_t *args) {
@@ -882,6 +888,7 @@ STATIC MP_DEFINE_CONST_DICT(lwip_socket_locals_dict, lwip_socket_locals_dict_tab
882888
STATIC const mp_obj_type_t lwip_socket_type = {
883889
{ &mp_type_type },
884890
.name = MP_QSTR_socket,
891+
.print = lwip_socket_print,
885892
.make_new = lwip_socket_make_new,
886893
.locals_dict = (mp_obj_t)&lwip_socket_locals_dict,
887894
};

0 commit comments

Comments
 (0)