Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

read(-1) blocking? #65

Open
GHamblin opened this issue Feb 22, 2021 · 6 comments
Open

read(-1) blocking? #65

GHamblin opened this issue Feb 22, 2021 · 6 comments

Comments

@GHamblin
Copy link

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?

@mikewadsten
Copy link
Contributor

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?

@GHamblin
Copy link
Author

GHamblin commented Feb 23, 2021 via email

@mikewadsten
Copy link
Contributor

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.

@GHamblin
Copy link
Author

GHamblin commented Feb 23, 2021 via email

@mikewadsten
Copy link
Contributor

So begin = stdin.buffer.read(-1) should be a line by itself, followed by an
if begin: ?

Yes, exactly.

@GHamblin
Copy link
Author

GHamblin commented Feb 23, 2021 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants