Lopy4 issue receiving in a tight loop
-
I have the following bit of code.
from network import LoRa import socket import time import pycom # Please pick the region that matches where you are using the device pycom.heartbeat(False) lora = LoRa(mode=LoRa.LORA, region=LoRa.EU868, bandwidth=LoRa.BW_250KHZ,coding_rate=LoRa.CODING_4_5,sf=7, tx_power=14,power_mode=LoRa.ALWAYS_ON,preamble=8, tx_iq=False, rx_iq=False) # >17000 bps s = socket.socket(socket.AF_LORA, socket.SOCK_RAW) s.setblocking(False) i = 0 while True: data=s.recv(512) if len(data)>0: print('count {0} value {1} length {2}'.format(i,data,len(data))) i = i+1 pycom.rgbled(0xFFD058) time.sleep_ms(2) pycom.rgbled(0x000000) time.sleep_ms(2) time.sleep_ms(1)I receive data well, except when I comment out the 1ms delay in the while loop. In which case I receive no data at all. The transmissions are happening slowly. About every 1 second.
-
Because you have an infinite loop, removing the delay will leave no time for the watchdog timer to trigger, making the device reset internally. You can perhaps use
time.sleep_us(...)instead?Gijs
-
This post is deleted! -
@Gijs Thank you for your response.
Any document I can read more about this? -
Its all in here: https://docs.pycom.io/firmwareapi/micropython/utime/
Note that the 'u' in front ofutimecan be left when importing, its the same moduleGijs
-
@Gijs What I meant was any documentation on the watchdog timer versus tight loops.
-
Right, we do not have specific documentation on that (yet) I believe, as in my experience its a fundamental feature of microcontrollers in general. Could you recommend a place where you would expect this information?
Gijs
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