Wiznet / RP2040-HAT-MicroPython

53 stars 22 forks source link

Udp broadcast support #9

Open lorismich opened 2 years ago

lorismich commented 2 years ago

The module turns on and I am able to receive an address via DHCP but when I try to initialize a UDP socket to transmit a broadcast package I received an error:

[code]>> import socket

socket.SOL_SOCKET Traceback (most recent call last): File "", line 1, in AttributeError: 'module' object has no attribute 'SOL_SOCKET'[/code]

Why SOL_SOCKET isn't defined ? I also tried with usocket module with the same result:

[code]>>> import usocket

usocket.SOL_SOCKET Traceback (most recent call last): File "", line 1, in AttributeError: 'module' object has no attribute 'SOL_SOCKET'[/code]

simryang commented 1 year ago

For my cases, it works. Which version do you use? I used W5100S_EVB_PICO-20230426-v1.20.0.uf2 file from https://micropython.org/download/W5100S_EVB_PICO/

>>> import usocket
>>> print(usocket, type(usocket))
<module 'lwip'> <class 'module'>
>>> print(dir(usocket))
['__class__', '__name__', '__dict__', 'AF_INET', 'AF_INET6', 'IPPROTO_IP', 'IP_ADD_MEMBERSHIP', 'IP_DROP_MEMBERSHIP', 'SOCK_DGRAM', 'SOCK_RAW', 'SOCK_STREAM', 'SOL_SOCKET', 'SO_REUSEADDR', 'callback', 'getaddrinfo', 'print_pcbs', 'reset', 'socket']
>>> print(usocket.SOL_SOCKET)
1