OSError: scan failed

All ESP8266 boards running MicroPython.
Official boards are the Adafruit Huzzah and Feather boards.
Target audience: MicroPython users with an ESP8266 board.
Post Reply
jamesb
Posts: 13
Joined: Tue Nov 29, 2016 3:31 am

OSError: scan failed

Post by jamesb » Sun Dec 18, 2016 3:00 am

wifi.scan() gives:

Code: Select all

>>> interface.scan()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
OSError: scan failed
I think it's when it can't see any wifi networks. I guess I'll enclose it in a try-except block, unless someone know a smart way around this?

eradicatore
Posts: 37
Joined: Thu Apr 20, 2017 9:19 pm

Re: OSError: scan failed

Post by eradicatore » Tue Oct 03, 2017 7:59 pm

Hi,
Were you able to confirm this happens if the scan results in no networks found? I was hitting OS error on scans in one location last night very repeatedly, so I would assume you're right. But I just expected the documentation to also mention this pretty interesting way of reporting nothing found (rather than just an empty tuple).

eradicatore
Posts: 37
Joined: Thu Apr 20, 2017 9:19 pm

Re: OSError: scan failed

Post by eradicatore » Thu Nov 16, 2017 8:21 pm

I still can't get the try/except to work around this failure when there are no wifi scan results. Does anyone else see this failure if there are zero ap's visible when you try to scan? Why would code like this not work?

Code: Select all

    try:
        scan_results = wifi.scan()
    except:
        ## for some odd reason OSERROR here means no wifi APs found
        scan_results = None
  

User avatar
pythoncoder
Posts: 1964
Joined: Fri Jul 18, 2014 8:01 am

Re: OSError: scan failed

Post by pythoncoder » Fri Nov 17, 2017 11:17 am

Hmm. That's a hard one to test unless you live in Greenland ;) My Faraday cage (AKA microwave oven) is too small for my laptop. Ideas anyone?
Peter Hinch

Post Reply