zephyr/modusocket: Wrap pkt_get_info() call.
The most important info it returns are numbers of free buffers in different pools (rx/tx packet headers, data fragments).
This commit is contained in:
parent
054a381d7c
commit
c022c9a2f0
@ -507,6 +507,18 @@ STATIC const mp_obj_type_t socket_type = {
|
|||||||
.locals_dict = (mp_obj_t)&socket_locals_dict,
|
.locals_dict = (mp_obj_t)&socket_locals_dict,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
STATIC mp_obj_t nbuf_get_info(void) {
|
||||||
|
struct net_buf_pool *rx, *tx, *rx_data, *tx_data;
|
||||||
|
net_nbuf_get_info(&rx, &tx, &rx_data, &tx_data);
|
||||||
|
mp_obj_tuple_t *t = MP_OBJ_TO_PTR(mp_obj_new_tuple(4, NULL));
|
||||||
|
t->items[0] = MP_OBJ_NEW_SMALL_INT(rx->avail_count);
|
||||||
|
t->items[1] = MP_OBJ_NEW_SMALL_INT(tx->avail_count);
|
||||||
|
t->items[2] = MP_OBJ_NEW_SMALL_INT(rx_data->avail_count);
|
||||||
|
t->items[3] = MP_OBJ_NEW_SMALL_INT(tx_data->avail_count);
|
||||||
|
return MP_OBJ_FROM_PTR(t);
|
||||||
|
}
|
||||||
|
STATIC MP_DEFINE_CONST_FUN_OBJ_0(nbuf_get_info_obj, nbuf_get_info);
|
||||||
|
|
||||||
STATIC const mp_map_elem_t mp_module_usocket_globals_table[] = {
|
STATIC const mp_map_elem_t mp_module_usocket_globals_table[] = {
|
||||||
{ MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_OBJ_NEW_QSTR(MP_QSTR_usocket) },
|
{ MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_OBJ_NEW_QSTR(MP_QSTR_usocket) },
|
||||||
// objects
|
// objects
|
||||||
@ -520,6 +532,8 @@ STATIC const mp_map_elem_t mp_module_usocket_globals_table[] = {
|
|||||||
|
|
||||||
{ MP_OBJ_NEW_QSTR(MP_QSTR_SOL_SOCKET), MP_OBJ_NEW_SMALL_INT(1) },
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_SOL_SOCKET), MP_OBJ_NEW_SMALL_INT(1) },
|
||||||
{ MP_OBJ_NEW_QSTR(MP_QSTR_SO_REUSEADDR), MP_OBJ_NEW_SMALL_INT(2) },
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_SO_REUSEADDR), MP_OBJ_NEW_SMALL_INT(2) },
|
||||||
|
|
||||||
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_nbuf_get_info), (mp_obj_t)&nbuf_get_info_obj },
|
||||||
};
|
};
|
||||||
|
|
||||||
STATIC MP_DEFINE_CONST_DICT(mp_module_usocket_globals, mp_module_usocket_globals_table);
|
STATIC MP_DEFINE_CONST_DICT(mp_module_usocket_globals, mp_module_usocket_globals_table);
|
||||||
|
@ -17,6 +17,9 @@ CONFIG_NET_TCP=y
|
|||||||
CONFIG_TEST_RANDOM_GENERATOR=y
|
CONFIG_TEST_RANDOM_GENERATOR=y
|
||||||
CONFIG_NET_NBUF_RX_COUNT=5
|
CONFIG_NET_NBUF_RX_COUNT=5
|
||||||
|
|
||||||
|
# Required for usocket.pkt_get_info()
|
||||||
|
CONFIG_NET_BUF_POOL_USAGE=y
|
||||||
|
|
||||||
# Uncomment to enable "INFO" level net_buf logging
|
# Uncomment to enable "INFO" level net_buf logging
|
||||||
#CONFIG_NET_LOG=y
|
#CONFIG_NET_LOG=y
|
||||||
#CONFIG_NET_DEBUG_NET_BUF=y
|
#CONFIG_NET_DEBUG_NET_BUF=y
|
||||||
|
Loading…
Reference in New Issue
Block a user