Adding timeout to

  • I am trying to read from the serial and telnet using Since the function is blocking, I tried some suggested options with uselect:

    import sys, uselect
    spoll.register(sys.stdin, uselect.POLLIN)
    def read1():
        return( if spoll.poll(0) else None)

    However, I get the following error: OSError: stream operation not supported on the following line: spoll.register(sys.stdin, uselect.POLLIN)

    Any suggestion for non-blocking read of UART and Telnet using non-blocking calls?

    Thank you in advance!

  • @jcaron unfortunately, there is any method with the stdin and I haven't found any way to interact directly with the telnet server.

    My previous implementation used the UART, but then I realized that I was able to read from Telnet, but no way to type anything. Also, the telnet connection was quite slow and unreliable for some reason (time out when login/password). With stdin it works much better, but not typing anything will block the application forever.

  • @berni have you tried setting it to non-blocking?

    If using the UART directly there is an any method which tells you if there’s data available, not sure if that is available via the stdin interface nor if that would work with telnet.

Pycom on Twitter