You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
During initial lease request, DHCPDISCOVER is sent and DHCPOFFER is received and processed correctly, but during the assembly of the DHCPREQUEST packet in send_dhcp_message() the following exception is thrown:
Traceback (most recent call last):
File "code.py", line 41, in
File "libs/socket.py", line 75, in init
File "/lib/adafruit_wiznet5k/adafruit_wiznet5k.py", line 226, in init
File "/lib/adafruit_wiznet5k/adafruit_wiznet5k.py", line 253, in set_dhcp
File "/lib/adafruit_wiznet5k/adafruit_wiznet5k_dhcp.py", line 536, in request_dhcp_lease
File "/lib/adafruit_wiznet5k/adafruit_wiznet5k_dhcp.py", line 450, in _dhcp_state_machine
File "/lib/adafruit_wiznet5k/adafruit_wiznet5k_dhcp.py", line 232, in send_dhcp_message
IndexError: index out of range
Adding some debug prints just above line 232 as follows:
...
_BUFF[254:after_hostname] = self._hostname
## Inserted debug
if self._debug:
print("after_hostname:", after_hostname)
print("Buffer length:", len(_BUFF))
## Inserted debug
if state == _DHCP_REQUEST and not renew:
...
produces the following output:
after_hostname: 272
Buffer length: 272
The buffer was initialized to 318 bytes long at line 89, but the clear at line 169 maintains the current length. I can only assume that somewhere in the processing of the DHCPOFFER reply, the buffer gets truncated to 272 bytes, which is then not enough for the DHCPREQUEST we're trying to send.
The fix that I applied was to change line 169 to this:
_BUFF = bytearray(318)
which does solve the problem. However rather than submit a pull request, I'd much prefer it if someone more familiar with this code can review the suggested change and make sure that it's not going to break anything else.
The text was updated successfully, but these errors were encountered:
During initial lease request, DHCPDISCOVER is sent and DHCPOFFER is received and processed correctly, but during the assembly of the DHCPREQUEST packet in send_dhcp_message() the following exception is thrown:
Traceback (most recent call last):
File "code.py", line 41, in
File "libs/socket.py", line 75, in init
File "/lib/adafruit_wiznet5k/adafruit_wiznet5k.py", line 226, in init
File "/lib/adafruit_wiznet5k/adafruit_wiznet5k.py", line 253, in set_dhcp
File "/lib/adafruit_wiznet5k/adafruit_wiznet5k_dhcp.py", line 536, in request_dhcp_lease
File "/lib/adafruit_wiznet5k/adafruit_wiznet5k_dhcp.py", line 450, in _dhcp_state_machine
File "/lib/adafruit_wiznet5k/adafruit_wiznet5k_dhcp.py", line 232, in send_dhcp_message
IndexError: index out of range
Adding some debug prints just above line 232 as follows:
produces the following output:
after_hostname: 272
Buffer length: 272
The buffer was initialized to 318 bytes long at line 89, but the clear at line 169 maintains the current length. I can only assume that somewhere in the processing of the DHCPOFFER reply, the buffer gets truncated to 272 bytes, which is then not enough for the DHCPREQUEST we're trying to send.
The fix that I applied was to change line 169 to this:
which does solve the problem. However rather than submit a pull request, I'd much prefer it if someone more familiar with this code can review the suggested change and make sure that it's not going to break anything else.
The text was updated successfully, but these errors were encountered: