Sockets with w5500 ethernet module

Discussion about programs, libraries and tools that work with MicroPython. Mostly these are provided by a third party.
Target audience: All users and developers of MicroPython.
Post Reply
gwork
Posts: 3
Joined: Sun Dec 09, 2018 3:51 am

Sockets with w5500 ethernet module

Post by gwork » Thu Jan 17, 2019 4:25 am

Hello all,

I am working with the STM32F4 Discovery board with the micropython port (including the w5500 driver) running on it. However, I am have some trouble working with the sockets library. Currently, my goal is to establish some communication with the board, so just an echo server would do (either TCP or UDP). I've primarily tried TCP connections, but I am experiencing several errors.

When I try usocket.getaddrinfo with local IP addresses, it resolves just fine. But when I use 'google.com' or 'micropython.org' and port 80 for HTTP, it fails to resolve and exits with the following error: OSError -2. Not very descriptive.

To confirm, I am connecting the board to the ethernet ports in my router, so it should be have internet access. The DNS server is 8.8.8.8 and it is on the right subnet... Not sure why it is giving this error.I only need a local network socket server though, as I don't intend to pull data from the internet, just inter computer communication. When I continue with creating the server, I do the following

s = usocket.socket(usocket.AF_INET, usocket.SOCK_STREAM)
addr = usocket.getaddrinfo('0.0.0.0', 8080)[0][-1]
s.bind(addr)
s.listen(1)
address, connection = s.accept() # <-- error here
print('accepted connection from ' + str(address))
s.close()

I marked where the error occurs. The error code is OSError: [Errno 107] ENOTCONN. Not sure why this is, because I am connected... (at least to the local network?)

Any help would be much appreciated

Post Reply