read(-1) blocking?
Opened this issue · 6 comments
It appears that sometimes stdin.buffer.read(-1) is blocking. Is there any way to determine if something is in the buffer before attempting to read from it?
Hi,
Would you be able to provide a simplified piece of example code which demonstrates this issue? Also, can you tell us which XBee product and firmware version you are seeing this on?
if (begin = stdin.buffer.read(-1)):
That is not (or should not be) valid Python/MicroPython. I take it you're coming from C or C++ (or similar language). Variable assignments in Python are not expressions, and you cannot do this. https://www.quora.com/Why-does-the-Python-assignment-not-return-a-value
If you send Ctrl-C while the program is hung, what line does the resulting traceback point to? That will tell you (and us) where it is hanging.
So begin = stdin.buffer.read(-1) should be a line by itself, followed by an
if begin: ?
Yes, exactly.