uasyncio server reader.read(len) getting cropped/truncated #9951
Replies: 3 comments 5 replies
-
I assume reader.read() follows the semantics of reading from as socket or a C/POSIX read().
readexactly() reads exactly the given bytes (and waits for more, when a simple read() returns too less). async def read(self, n=-1):
r = b""
while True:
yield core._io_queue.queue_read(self.s)
r2 = self.s.read(n)
if r2 is not None:
if n >= 0:
return r2
if not len(r2):
return r
r += r2
async def readexactly(self, n):
r = b""
while n:
yield core._io_queue.queue_read(self.s)
r2 = self.s.read(n)
if r2 is not None:
if not len(r2):
raise EOFError
r += r2
n -= len(r2)
return r |
Beta Was this translation helpful? Give feedback.
-
Just a thought... are there any multi-byte unicode characters being sent? I seem to recall being bitten by something similar in the past. I think with |
Beta Was this translation helpful? Give feedback.
-
@DavesCodeMusings: I don't think so, as |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Posted this on the raspberry pi forum a few days ago, 0 replies so I am trying here
Documentation: https://docs.micropython.org/en/latest/library/uasyncio.html#tcp-stream-connections
My full code: https://github.com/GM-Script-Writer-62850/PICO_W_Thermostat/blob/main/PICO/main.py#L836
I am sending some json to my pico via a post request (made here)
data length is 693 and it is getting cut off in the middle of a integer/time stamp at 683 chars
any idea what is going on here
Beta Was this translation helpful? Give feedback.
All reactions