Skip to content

Commit

Permalink
Merge pull request #42 from bjnhur/master
Browse files Browse the repository at this point in the history
fix buffer length var in socket_write()
  • Loading branch information
FoamyGuy authored Jan 3, 2022
2 parents 0444cb7 + 1873377 commit d93071f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions adafruit_wiznet5k/adafruit_wiznet5k.py
Original file line number Diff line number Diff line change
Expand Up @@ -744,11 +744,12 @@ def socket_write(self, socket_num, buffer, timeout=0):
dst_addr = offset + (socket_num * 2048 + 0x8000)

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

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

self._write_sncr(socket_num, CMD_SOCK_SEND)
self._read_sncr(socket_num)
Expand Down Expand Up @@ -863,9 +864,8 @@ def _read_snmr(self, sock):

def _write_socket(self, sock, address, data):
"""Write to a W5k socket register."""
base = self._ch_base_msb << 8
cntl_byte = (sock << 5) + 0x0C
return self.write(base + sock * CH_SIZE + address, cntl_byte, data)
return self.write(address, cntl_byte, data)

def _read_socket(self, sock, address):
"""Read a W5k socket register."""
Expand Down

0 comments on commit d93071f

Please sign in to comment.