Lopy LoRa socket timeout
-
Hi, I’m noob with python and lora, I want to open a socket wait for a message, if there is no message then do something else, my code so far is:
from network import LoRa import socket import machine import time import binascii import network n = 0 try: the_sock = socket.socket(socket.AF_LORA, socket.SOCK_RAW) except: exit('Error creating socket.') the_sock.settimeout(5) while True: try: n+=1 print("Hola"+str(n)) the_sock.setblocking(True) ack = the_sock.recv(64) except socket.timeout, e: err = e.args[0] print(err) break`The problem is that the timeout it’s not working, I’ve checked some answers but the code looks good to me, can you help me please?
Kind Regards
-
@ahelllycan
change this tothe_sock.settimeout(5) ack = the_sock.recv(64)setblocking is only shortcut for timeout
if you settimeout first and then setblocking you change timeout to nonesummary
settimeout(None)==setblocking(True)
settimeout(0)==setblocking(False)
settimeout(5)--- no equivalent in setblocking -
@livius Thank you so much!!! that's exactly what I needed
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login