Test code to count 30Hz is standard:
Code: Select all
ctr = 0
def cbInt(p):
global ctr
ctr = ctr + 1
def xstart(lock):
pin = Pin(27, Pin.IN)
pin.irq(trigger = Pin.IRQ_RISING, handler = cbInt)
Code: Select all
async def loop():
global ctr
while True:
irqs = machine.disable_irq()
tmp = ctr
ctr = 0
machine.enable_irq(irqs)
print(tmp)
await asyncio.sleep(10)
I know getaddrinfo is blocking, so I put interrupt routine in separate thread, with no improvement. I assume the problem lies in mp_sched_schedule still waiting for getaddrinfo to finish.
1. Is this assumption correct?
2. Does the same problem exist e.g. with 1wire driver in combination with MQTT?
3. Besides using static IP (nope), is there a way to instruct DNS resolver to use cached value for longer time?
4. Is there other solution besides writing external C module?