Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 4919

MicroPython • Re: Function route() in module network

$
0
0
There are a number of methods not documented by MicroPython and I am not sure what they do or how they should be used. Looking at the source code ....

https://github.com/micropython/micropython/blob/master/extmod/modnetwork.c#L102

Code:

static mp_obj_t network_route(void) {    return MP_OBJ_FROM_PTR(&MP_STATE_PORT(mod_network_nic_list));}static MP_DEFINE_CONST_FUN_OBJ_0(network_route_obj, network_route);
So it seems to be read-only and returning a list of registered NIC's. Though it always returns an empty list for me. I presume that's because there is only one NIC on the Pico W and everything is routed through that. If you crafted MicroPython firmware for the WIZnet wired Ethernet boards, added an RM2 module and supported Ethernet over USB, it might contain a list of all three.

The list appears to be used to determine what an IP address should be when doing some DNS lookups and may be used elsewhere ....

https://github.com/micropython/micropython/blob/master/extmod/modsocket.c#L586

Code:

    if (!have_ip) {        // find a NIC that can do a name lookup        for (mp_uint_t i = 0; i < MP_STATE_PORT(mod_network_nic_list).len; i++) {            ...
You would need to ask MicroPython for greater insight or dig through the source code to figure it out.

Statistics: Posted by hippy — Fri Oct 18, 2024 11:50 am



Viewing all articles
Browse latest Browse all 4919

Trending Articles