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

    Detect board type or availble services?

    Scheduled Pinned Locked Moved Discussion
    design guidelopysipy
    6 Posts 2 Posters 1.6k 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.
    • M Offline
      misterlisty
      last edited by misterlisty

      Is it possible to detect what radios are avaible on the board? I have some code that i wish to auto-enable/disable code based on whether the board has sigfox,lora,lte- me? Is their a inbuilt variable that will indicate this"?

      File "boot.py", line 15, in <module>
      ImportError: cannot import name LoRa from a sipyboard, how do safely handle this?

      robert-hhR 1 Reply Last reply Reply Quote 0
      • robert-hhR Offline
        robert-hh @misterlisty
        last edited by

        @misterlisty You can use the output of uos.uname(), which returns a tuple with machine details. On a LoPy, uos.uname().sysname has the value "LoPy".

        1 Reply Last reply Reply Quote 1
        • M Offline
          misterlisty
          last edited by

          thanks but can i create conditional imports?

          if bLora:
          from network import LoRa #shuold this work?

          robert-hhR 1 Reply Last reply Reply Quote 0
          • robert-hhR Offline
            robert-hh @misterlisty
            last edited by robert-hh

            @misterlisty Python is an interpreting language, and Import statements get effective only when the statement is executed, unlike #includes of C. Simple test on a WiPy:

            import uos
            if uos.uname().sysname == "LoPy":
                from network import LoRa
            else:
                print ("not LoPy")
            
            M 1 Reply Last reply Reply Quote 0
            • M Offline
              misterlisty @robert-hh
              last edited by

              @robert-hh Why do you use uos.uname() when i have to use os.uname(), even the doco refers to a presffix of u for some reason?

              robert-hhR 1 Reply Last reply Reply Quote 0
              • robert-hhR Offline
                robert-hh @misterlisty
                last edited by

                @misterlisty Micropython uses the prefix u for its modules to indicate, that it may be a subset of what you have in CPython. For compatibility, the names without u are also provided. So, the genric name in MicroiPyhton is uos.uname, while os.uname is also possible. Likewise, you can write

                import uos
                or
                import os

                There are some deviations from that simple rule. Like in CPython, you can use _io, whereas in Micropython it's called uio (not u_io), and _io is not known. Also, why some modules have a non-u alias and others not is unclear. You could change that easily in mpconfigport.h of the respective port.

                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