Closed pinkavaj closed 6 months ago
This makes sense as far as I can tell but I lack the specific knowledge about the lower level details so I may not be the best to review.
I did test this branch successfully with the simpletest script in this repo on a Feather RP2040 + Ethernet Featherwing.
I attempted to test the specific path of code that contains the change but couldn't figure out how. I tried adding some sleep inside of recv_into (to give myself more time to react) and then unplugging the ethernet cable while a request was being received. I'm not really sure if that is a correct way to test this, but in my case it was raising this exception from inside the if
block that this elif was added to rather than making it to the elif and using the new code.
Traceback (most recent call last):
File "code.py", line 23, in <module>
File "/lib/adafruit_wiznet5k/adafruit_wiznet5k.py", line 262, in __init__
File "/lib/adafruit_wiznet5k/adafruit_wiznet5k.py", line 276, in set_dhcp
File "/lib/adafruit_wiznet5k/adafruit_wiznet5k_dhcp.py", line 183, in request_dhcp_lease
File "/lib/adafruit_wiznet5k/adafruit_wiznet5k_dhcp.py", line 426, in _dhcp_state_machine
File "/lib/adafruit_wiznet5k/adafruit_wiznet5k_dhcp.py", line 343, in _handle_dhcp_message
File "/lib/adafruit_wiznet5k/adafruit_wiznet5k.py", line 562, in socket_connect
File "/lib/adafruit_wiznet5k/adafruit_wiznet5k.py", line 1060, in _check_link_status
ConnectionError: The Ethernet connection is down.
I think to test, we would need a way to kill the socket from the other side. I wonder if you setup one device as a webserver, and then during that wait, power that device off, if you would get the right thing (because then the socket would be closed). You could also spin up something local if that's easier.
We cannot get more date on closed socket, return what we have, if anythink.
Closes #135