Skip to content

Commit 00f0cba

Browse files
author
brentru
committed
add rxbuff
1 parent 1743043 commit 00f0cba

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

adafruit_wiznet5k/adafruit_wiznet5k.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,7 @@ def __init__(self, spi_bus, cs, reset=None,
166166

167167
# Buffer for reading params from module
168168
self._pbuff = bytearray(8)
169-
170-
171-
self._rbuf = bytearray(1)
169+
self._rxbuf = bytearray(MAX_PACKET)
172170

173171
# attempt to initialize the module
174172
self._ch_base_msb = 0
@@ -395,22 +393,28 @@ def read(self, addr, callback, length=1, buffer=None):
395393
return buffer
396394

397395
def write(self, addr, callback, data):
396+
"""Write data to a register address.
397+
:param int addr: Destination address.
398+
:param int callback: Callback reference.
399+
:param int data: Data to write, as an integer.
400+
:param bytearray data: Data to write, as a bytearray.
401+
402+
"""
398403
with self._device as bus_device:
399404
bus_device.write(bytes([addr >> 8]))
400405
bus_device.write(bytes([addr & 0xFF]))
401406
bus_device.write(bytes([callback]))
402407

403-
if hasattr(data,'from_bytes'):
408+
if hasattr(data, 'from_bytes'):
404409
bus_device.write(bytes([data]))
405410
else:
406411
for i, _ in enumerate(data):
407412
bus_device.write(bytes([data[i]]))
408-
return len
409-
410413

411414
# Socket-Register API
412-
413415
def _udp_remaining(self):
416+
if self._debug:
417+
print("* UDP Bytes Remaining: ", UDP_SOCK['bytes_remaining'])
414418
return UDP_SOCK['bytes_remaining']
415419

416420
def socket_available(self, socket_num, sock_type=SNMR_TCP):
@@ -425,7 +429,6 @@ def socket_available(self, socket_num, sock_type=SNMR_TCP):
425429
assert socket_num <= self.max_sockets, "Provided socket exceeds max_sockets."
426430

427431
if sock_type == 0x02:
428-
print('UDP: ', UDP_SOCK['bytes_remaining'])
429432
# flush by reading remaining data from previous packet
430433
while UDP_SOCK['bytes_remaining'] > 0 and self.socket_read(socket_num, 1):
431434
if self._debug:
@@ -435,7 +438,6 @@ def socket_available(self, socket_num, sock_type=SNMR_TCP):
435438

436439
res = self._get_rx_rcv_size(socket_num)
437440

438-
print('Res: ', res)
439441
res = int.from_bytes(res, 'b')
440442
if sock_type == SNMR_TCP:
441443
return res
@@ -572,8 +574,6 @@ def socket_read_udp(self, socket_num, length):
572574
UDP_SOCK['bytes_remaining'] -= ret
573575
if self._debug:
574576
print("UDP read {0} bytes: ".format(ret))
575-
print(UDP_SOCK['bytes_remaining'])
576-
print(resp)
577577
return ret, resp
578578
# failed to read or no data
579579
return -1
@@ -617,7 +617,6 @@ def socket_read(self, socket_num, length):
617617
# Read data from the starting address of snrx_rd
618618
ctrl_byte = (0x18+(socket_num<<5))
619619

620-
print("Read data, len={}, at: {}".format(ret, ptr))
621620
resp = self.read(ptr, ctrl_byte, ret)
622621

623622
# After reading the received data, update Sn_RX_RD to the increased

0 commit comments

Comments
 (0)