Welcome to the Pycom forum Forum
    • \[\[global:header.categories\]\]
    • \[\[global:header.recent\]\]
    • \[\[global:header.tags\]\]
    • \[\[global:header.popular\]\]
    • Login

    Explore Pybytes | Official Documentation | Report a Firmware Bug/Issue | GitHub

    OSError: Network card not available after updating firmware via OTA

    Scheduled Pinned Locked Moved LoPy
    4 Posts 2 Posters 89 Views 2 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • D Offline
      d.alvrzx
      last edited by

      Hello all!

      On occasion, when I update a LoPy4 via OTA (transferring appimg.bin to /flash/sys and then rebooting), I get the following exception when running standard code in my LoPy4:

      OSError: Network card not available
      

      The exception is thrown on this line:

      s_app = socket.socket()
      

      What could be causing this? The only way I have found of solving the problem has been re-flashing the firmware.

      Any insights are appreciated.

      Best,

      Dan

      1 Reply Last reply Reply Quote 0
      • G Offline
        Gijs
        last edited by

        Hi,
        I get exactly the same (without the OTA transfer), if i do not define a network first. I'll show you an example:

        >>> import socket
        >>> s = socket.socket()
        Traceback (most recent call last):
          File "<stdin>", line 1, in <module>
        OSError: Network card not available
        >>> from network import WLAN
        >>> wlan = WLAN()
        >>> wlan.init()
        >>> wlan.connect(ssid='Pycom', auth=(WLAN.WPA2, 'PyE!ndh0ven#'))
        >>> wlan.isconnected()
        False
        >>> wlan.isconnected()
        True
        >>> s = socket.socket()
        >>> 
        

        Which is logical. What you need to do is connect to a network first. What might be the case, is that either Pybytes is activated, or some wlan or lte on boot setting is activated in the background before calling socket.socket() making the error not appear.
        Its also best practice to specify the type of network you want to use like so
        s = socket.socket(usocket.AF_INET)

        Gijs

        D 1 Reply Last reply Reply Quote 1
        • D Offline
          d.alvrzx @Gijs
          last edited by

          @Gijs Hello! Thank you for your reply.

          In fact, I do define a network beforehand. In boot.py I run the following code, always:

          currSSID = WLAN().ssid()
          WLAN().deinit()
          WLAN().init(mode=WLAN.AP, ssid=currSSID, auth=(WLAN.WPA2, 'pwd'), hidden=True, antenna=WLAN.INT_ANT)
          

          And then, in main.py I first initialize a LoRa socket (which goes smoothly) and then initialize the WLAN socket via s_app = socket.socket().

          However, I have not tried indicating the exact type of network to use in the socket. Could this be the culprit? I will try to reproduce the error.

          Best,

          Dan

          1 Reply Last reply Reply Quote 0
          • G Offline
            Gijs
            last edited by

            Last week I did check out the code for a bit, and when no network adapter is explicitely specified, it should default to AF_INET (thats WLAN or LTE). Im not exactly sure what is happening on your end. Do you check whether the network is connected beforehand (ie wlan.isconnected() should return True, it could take a couple of seconds for the WiFi handshake to complete)

            Let me know what you find

            Gijs

            1 Reply Last reply Reply Quote 0

            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
            • 1 / 1
            • First post
              Last post

            Pycom on Twitter

            Pycom