Detect board type or availble services?
-
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? -
@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".
-
thanks but can i create conditional imports?
if bLora:
from network import LoRa #shuold this work? -
@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") -
@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?
-
@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 osThere 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.
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