Skip to content

Commit fce3410

Browse files
authored
Merge pull request #44 from cpforbes/socket_timeout
2 fixes for adafruit_esp32spi_socket.socket
2 parents 1fe7e85 + 83f46d2 commit fce3410

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

adafruit_esp32spi/adafruit_esp32spi_socket.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ def connect(self, address, conntype=None):
7373
a hostname string). 'conntype' is an extra that may indicate SSL or not,
7474
depending on the underlying interface"""
7575
host, port = address
76+
if conntype is None:
77+
conntype = _the_interface.TCP_MODE
7678
if not _the_interface.socket_connect(self._socknum, host, port, conn_mode=conntype):
7779
raise RuntimeError("Failed to connect to host", host)
7880
self._buffer = b''
@@ -123,7 +125,7 @@ def read(self, size=0):
123125
received.append(recv)
124126
to_read -= len(recv)
125127
gc.collect()
126-
if time.monotonic() - stamp > self._timeout:
128+
if self._timeout > 0 and time.monotonic() - stamp > self._timeout:
127129
break
128130
#print(received)
129131
self._buffer += b''.join(received)

0 commit comments

Comments
 (0)