summaryrefslogtreecommitdiffstatshomepage
path: root/ports/zephyr/modusocket.c
diff options
context:
space:
mode:
authorPTH <thomas@pth.systems>2021-02-12 15:08:02 +0100
committerDamien George <damien@micropython.org>2021-02-17 10:42:43 +1100
commit5cb91afb9b3b34bbf0ee022a3f69af90c01d1d54 (patch)
tree5d2abc2aa34633b70adb3dfb69b53b0e3a255967 /ports/zephyr/modusocket.c
parent6c4a5d185d7e70c22c0f72fb1cd8add251600548 (diff)
downloadmicropython-5cb91afb9b3b34bbf0ee022a3f69af90c01d1d54.tar.gz
micropython-5cb91afb9b3b34bbf0ee022a3f69af90c01d1d54.zip
zephyr/modusocket: Fix parameter in calls to net_context_get_XXX().
The following simple usocket example throws an error EINVAL on connect import usocket s = usocket.socket() s.connect(usocket.getaddrinfo('www.micropython.org', 80)[0][-1]) Traceback (most recent call last): File "<stdin>", line 1, in <module> OSError: [Errno 22] EINVAL Fixing the context parameter in calls of net_context_get_family() and net_context_get_type(), the connect works fine. Tested on a nucleo_h743zi board.
Diffstat (limited to 'ports/zephyr/modusocket.c')
-rw-r--r--ports/zephyr/modusocket.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/ports/zephyr/modusocket.c b/ports/zephyr/modusocket.c
index 6c900753c8..f9fc96a2b1 100644
--- a/ports/zephyr/modusocket.c
+++ b/ports/zephyr/modusocket.c
@@ -79,7 +79,8 @@ STATIC void parse_inet_addr(socket_obj_t *socket, mp_obj_t addr_in, struct socka
mp_obj_t *addr_items;
mp_obj_get_array_fixed_n(addr_in, 2, &addr_items);
- sockaddr_in->sin_family = net_context_get_family((void *)socket->ctx);
+ void *context = zsock_get_context_object(socket->ctx);
+ sockaddr_in->sin_family = net_context_get_family(context);
RAISE_ERRNO(net_addr_pton(sockaddr_in->sin_family, mp_obj_str_get_str(addr_items[0]), &sockaddr_in->sin_addr));
sockaddr_in->sin_port = htons(mp_obj_get_int(addr_items[1]));
}
@@ -119,8 +120,8 @@ STATIC void socket_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kin
if (self->ctx == -1) {
mp_printf(print, "<socket NULL>");
} else {
- struct net_context *ctx = (void *)self->ctx;
- mp_printf(print, "<socket %p type=%d>", ctx, net_context_get_type(ctx));
+ void *context = zsock_get_context_object(self->ctx);
+ mp_printf(print, "<socket %p type=%d>", self->ctx, net_context_get_type(context));
}
}