Hi All,
I've followed all advice found on the net, but the problem continues unabated. After roughly 5 post requests with urequests, the LmacRxBlk:1 occurs and does not cease until I hard reset. A soft reboot has no effect.
The latest code is below, as is the debug info. I have used two different versions of urequests. They get the same problem. The latest version I've tried is the one by J.G.Davies.
Any advice on whether my code sucks and how to fix it will be treated like gold.
My code:
import sys
import time
import machine
import dht
import urequests
bool_interrupt = False
last_interrupt = time.time()
NOTIFICATION = "https://api.prowlapp.com/publicapi/add? ... ORTHISPOST"
def blink_led(count, delay):
for x in range(0, count - 1):
if pin_led.value():
pin_led.low()
else:
pin_led.high()
time.sleep(delay)
pin_led.value(0)
def callback(p):
global bool_interrupt
bool_interrupt = True
print(bool_interrupt)
pin_led = machine.Pin(13, machine.Pin.OUT)
pin_vibration = machine.Pin(14, machine.Pin.IN)
temp = dht.DHT11(machine.Pin(0))
#d.measure()
#print(d.temperature())
# Tell everyone we are awake
blink_led(8, 0.5)
# now set interrupt for movement
pin_vibration.irq(trigger=machine.Pin.IRQ_FALLING, handler=callback)
url = NOTIFICATION
wlan = network.WLAN(network.STA_IF)
while True:
if wlan.isconnected() == False:
print('WiFi disconnected')
break
if bool_interrupt:
this_interrupt = time.time()
if this_interrupt - last_interrupt < 5:
print('avoid interrupt')
else:
print('interrupt')
resp = urequests.urlopen(url, 'method=POST')
print(resp)
last_interrupt = this_interrupt
blink_led(6, 0.3)
bool_interrupt = False
# time.sleep(1)
The console log:
#6 ets_task(40100164, 3, 3fff828c, 4)
network config: ('192.168.1.44', '255.255.255.0', '192.168.1.1', '192.168.1.1')
True
True
interrupt
True
True
<_SSLSocket 3fff2b10>
True
True
interrupt
<_SSLSocket 3fff4420>
True
True
interrupt
True
True
True
True
True
True
True
True
True
True
<_SSLSocket 3fff2b10>
True
interrupt
True
True
<_SSLSocket 3fff65f0>
True
True
interrupt
True
True
True
True
True
True
True
True
True
True
<_SSLSocket 3fff2ed0>
LmacRxBlk:1
LmacRxBlk:1
LmacRxBlk:1
LmacRxBlk:1
LmacRxBlk:1
LmacRxBlk:1
LmacRxBlk:1
LmacRxBlk:1
LmacRxBlk:1
LmacRxBlk:1
LmacRxBlk:1
LmacRxBlk:1
LmacRxBlk:1
LmacRxBlk:1
LmacRxBlk:1
LmacRxBlk:1
LmacRxBlk:1
LmacRxBlk:1
LmacRxBlk:1
LmacRxBlk:1
LmacRxBlk:1
LmacRxBlk:1
LmacRxBlk:1
LmacRxBlk:1
LmacRxBlk:1 continues unabated - every time I don't close the sockets
Re: LmacRxBlk:1 continues unabated
Did you read the official documentation: http://docs.micropython.org/en/latest/e ... -resources ?
Awesome MicroPython list
Pycopy - A better MicroPython https://github.com/pfalcon/micropython
MicroPython standard library for all ports and forks - https://github.com/pfalcon/micropython-lib
More up to date docs - http://pycopy.readthedocs.io/
Pycopy - A better MicroPython https://github.com/pfalcon/micropython
MicroPython standard library for all ports and forks - https://github.com/pfalcon/micropython-lib
More up to date docs - http://pycopy.readthedocs.io/
Re: LmacRxBlk:1 continues unabated
Thanks for the response. Yes I did read the guide. I guess, from your cryptic response, that you are implying one should not use the available code for urequest, but rather create your own socket code where you have better control over the release of sockets.
I'm probably going to move away from that technique and rather use MQTT or some such.
I'm probably going to move away from that technique and rather use MQTT or some such.
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: LmacRxBlk:1 continues unabated
I'm no networking guru, but looking at the official urequests module the request() function returns a Response instance. This supports a close() method; this closes the socket which was created by request(). I think Paul is suggesting you use this to ensure sockets are closed after use.
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.
Re: LmacRxBlk:1 continues unabated
Thanks pythoncoder. I changed to the urlopen module and added a socket.close(). Works fine now. However, it does seem that MQTT will be more suitable for my purposes. Another learning curve coming up...
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: LmacRxBlk:1 continues unabated
You might like to look at viewtopic.php?f=16&t=2239&p=12680&hilit ... FAQ#p12680.
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.
Re: LmacRxBlk:1 continues unabated
There's nothing cryptic. The quoted documentation section states clearly:alanm101 wrote:I guess, from your cryptic response
Neither there's a need to modify anything - you just need to close (as in: call ".close()" method on them) any resources you finished dealing with, e.g a stream object you got from urlopen() call.please be sure to close open files, sockets, etc. as soon as possible after use.
Awesome MicroPython list
Pycopy - A better MicroPython https://github.com/pfalcon/micropython
MicroPython standard library for all ports and forks - https://github.com/pfalcon/micropython-lib
More up to date docs - http://pycopy.readthedocs.io/
Pycopy - A better MicroPython https://github.com/pfalcon/micropython
MicroPython standard library for all ports and forks - https://github.com/pfalcon/micropython-lib
More up to date docs - http://pycopy.readthedocs.io/
Re: LmacRxBlk:1 continues
@Alarm101
How have you progressed using MQTT in your setup? Success? Not? If you have been successful, it would be great to see your code as I too am having this issue.
TIA, JNA.
How have you progressed using MQTT in your setup? Success? Not? If you have been successful, it would be great to see your code as I too am having this issue.
TIA, JNA.