Skip to content

Commit c431cf7

Browse files
author
Bongjun Hur
committed
fix buffer length var in socket_write()
1 parent f00a3f7 commit c431cf7

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

adafruit_wiznet5k/adafruit_wiznet5k.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -744,11 +744,12 @@ def socket_write(self, socket_num, buffer, timeout=0):
744744
dst_addr = offset + (socket_num * 2048 + 0x8000)
745745

746746
# update sn_tx_wr to the value + data size
747-
ptr = (ptr + len(buffer)) & 0xFFFF
747+
ptr = (ptr + ret) & 0xFFFF
748748
self._write_sntx_wr(socket_num, ptr)
749749

750750
cntl_byte = 0x14 + (socket_num << 5)
751-
self.write(dst_addr, cntl_byte, buffer)
751+
txbuf = buffer[:ret] # <- use ret
752+
self.write(dst_addr, cntl_byte, txbuf)
752753

753754
self._write_sncr(socket_num, CMD_SOCK_SEND)
754755
self._read_sncr(socket_num)

0 commit comments

Comments
 (0)