Skip to content

Commit a52fcf0

Browse files
author
brentru
committed
add reliable readline
1 parent cd81053 commit a52fcf0

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

adafruit_fona/adafruit_fona.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -607,7 +607,6 @@ def socket_available(self, sock_num):
607607
:param int sock_num: Desired socket to return bytes available from.
608608
609609
"""
610-
self._read_line()
611610
assert (
612611
sock_num < FONA_MAX_SOCKETS
613612
), "Provided socket exceeds the maximum number of \
@@ -617,10 +616,14 @@ def socket_available(self, sock_num):
617616
b"+CIPRXGET: 4," + str(sock_num).encode() + b",",
618617
):
619618
return False
619+
data = self._buf
620620
if self._debug:
621621
print("\t {} bytes available.".format(self._buf))
622622

623-
return self._buf
623+
self._read_line()
624+
self._read_line()
625+
626+
return data
624627

625628
def socket_connect(self, sock_num, dest, port, conn_mode=TCP_MODE):
626629
"""Connects to a destination IP address or hostname.

adafruit_fona/adafruit_fona_socket.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ def recv(self, bufsize=0):
210210

211211
def readline(self):
212212
"""Attempt to return as many bytes as we can up to but not including '\r\n'"""
213-
print("Socket readline")
213+
# print("Socket readline")
214214
stamp = time.monotonic()
215215
while b"\r\n" not in self._buffer:
216216
# there's no line already in there, read some more

0 commit comments

Comments
 (0)