Skip to content

Commit 7f9e3e3

Browse files
committed
Merge branch 'master' of github.com:ladyada/Adafruit_CircuitPython_ESP32SPI
2 parents 6fe5722 + 4c41d03 commit 7f9e3e3

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

adafruit_esp32spi/adafruit_esp32spi.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,8 @@ def socket_available(self, socket_num):
515515
def socket_read(self, socket_num, size):
516516
"""Read up to 'size' bytes from the socket number. Returns a bytearray"""
517517
if self._debug:
518-
print("Reading %d bytes from socket with status %d" % (size, self.socket_status(socket_num)))
518+
print("Reading %d bytes from socket with status %d" %
519+
(size, self.socket_status(socket_num)))
519520
resp = self._send_command_get_response(_GET_DATABUF_TCP_CMD,
520521
[[socket_num], [size & 0xFF, (size >> 8) & 0xFF]],
521522
sent_param_len_16=True, recv_param_len_16=True)

adafruit_esp32spi/adafruit_esp32spi_requests.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,14 @@ def json(self):
107107
return ujson.loads(self.content)
108108

109109
def iter_content(self, chunk_size=1, decode_unicode=False):
110+
"""An iterator that will stream data by only reading 'chunk_size'
111+
bytes and yielding them, when we can't buffer the whole datastream"""
110112
if decode_unicode:
111113
raise NotImplementedError("Unicode not supported")
112114

113115
while True:
114116
chunk = self.socket.read(chunk_size)
115-
if chunk and len(chunk) > 0:
117+
if chunk:
116118
yield chunk
117119
else:
118120
return

adafruit_esp32spi/adafruit_esp32spi_socket.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,8 @@ def read(self, size=0):
114114
return ret
115115

116116
def settimeout(self, value):
117+
"""Set the reading timeout for sockets before we return with fewer
118+
or no data on read(). If set to 0 we are fully blocking"""
117119
self._timeout = value
118120

119121
def close(self):

0 commit comments

Comments
 (0)