We have upgraded the community system as part of the upgrade a password reset is required for all users before login in.

Omega2 Dash ADC EXP (Python) not connecting.



  • @tjoseph1

    root@Omega-C592:~# python --version
    Python 2.7.18
    root@Omega-C592:~# python
    Python 2.7.18 (default, Jul 14 2020, 21:51:14)
    [GCC 7.3.0] on linux2
    Type "help", "copyright", "credits" or "license" for more information.

    from OmegaExpansion import relayExp
    import time
    locals()
    {'builtins': <module 'builtin' (built-in)>, 'relayExp': <module 'OmegaExpansion.relayExp' from '/usr/lib/python2.7/OmegaExpansion/relayExp.so'>, 'package': None, 'time': <module 'time' from '/usr/lib/python2.7/lib-dynload/time.so'>, 'name': 'main', 'doc': None}

    Is this what you meant to do above? It seams like it works.

    I already have this entire setup running on the dash and all the sensors work and all the omegaexpansion modules as well. It just does not work when I run the micropython command.

    Can this too be sym linked?



  • @LightSwitch

    root@Omega-C592:~# python --version
    Python 2.7.18
    root@Omega-C592:~# python
    Python 2.7.18 (default, Jul 14 2020, 21:51:14)
    [GCC 7.3.0] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>> from OmegaExpansion import relayExp
    >>> import time
    >>> locals()
    {'__builtins__': <module '__builtin__' (built-in)>, 'relayExp': <module 'OmegaExpansion.relayExp' from '/usr/lib/python2.7/OmegaExpansion/relayExp.so'>, '__package__': None, 'time': <module 'time' from '/usr/lib/python2.7/lib-dynload/time.so'>, '__name__': '__main__', '__doc__': None}
    >>>
    


  • @LightSwitch :

    Even though the online docs provide examples based on python2, there are corresponding python3 packages available.

    root@Omega-745F:~# opkg list | grep -i omega | grep -i exp
    pyOmegaExpansion - 0.9-1 - Setup for OmegaExpansion Python Package (I guess this is python2)
    python3-omega-expansion - 0.9-1 - Setup for OmegaExpansion Python3 Package (python3)

    root@Omega-745F:~# opkg list | grep -i py | grep -i relay
    pyRelayExp - 0.9-1 - Python module to control the Onion Relay Expansion (this is python2)
    python3-relay-exp - 0.9-1 - Python3 module to control the Onion Relay Expansion (python3)

    As the docs say, the programs make use of the underlying i2c C libs. Onion programmers have created the python2/3 libs for both ADC/Relay Exp that can interact with the "base" C libs. Those are the above packages.

    I do not see any equivalent micropython packages in the repo. My best guess is that micropython Relay Exp is not an option, unless you create your own python packages using the C source of i2c.
    https://github.com/OnionIoT/i2c-exp-driver

    Here the basic howto:
    https://docs.micropython.org/en/latest/develop/cmodules.html#
    to create a C lib that can be called from micropython.

    Since you already have the required h/w docks, you can give it a try.. or stay with the python3 packages that Onion repos provide.

    Or request the Onion team to provide micropython packages for Relay Exp. The micropython port is not of much use unless Onion team extends the py lib support to the entire range of Docks as they have done in the case of py2 and py3.

    Is the ADC Exp working fine from micropython ? I can only import; but won't be able to create objects since I do not have ADC Exp.

    Thanks..



  • @tjoseph1 @LightSwitch Not sure if Onion will update this libraries since the relay expansion is discontinued:

    https://onion.io/discontinuing-3-expansion-and-a-kit/



  • @crispyoz :

    Yes. The chances of supporting a "discontinued" h/w is almost nil.

    If we consider py2, py3 and micropython are 3 different streams of py the libs have to be made available in all three. Many developers are using python, all 3 variants of it. May be there is a reason Onion didn't release the libs that work with micropython ?

    It can still be ordered, say from mouser.com (sparkfun make)
    https://www.mouser.com/ProductDetail/SparkFun/DEV-14444?qs=wd5RIQLrsJgP0vNuuZBr2Q%3D%3D

    A "HOWTO" to build the micropython modules would be helpful and appreciated very much. People do not have to spend hours/days knitting pieces of information scattered all over the Internet into a working procedure-set. And the sad part is, it not sure if if is ever going to work, until we see it working...

    While running the time.sleep(10) py script, py3 takes 2MB straight, and micropython takes about 100kB+.

    root@Omega-745F:~# free
    total used free shared buffers cached
    Mem: 124808 56120 68688 92 15988 18588

    root@Omega-745F:~# python3 sleep.py &

    root@Omega-745F:~# free
    total used free shared buffers cached
    Mem: 124808 58172 66636 92 15988 18588

    root@Omega-745F:~# python3 sleep.py &

    root@Omega-745F:~# free
    total used free shared buffers cached
    Mem: 124808 60280 64528 92 15988 18588

    root@Omega-745F:~# ps
    1989 root 5512 S python3 sleep.py
    1991 root 5512 S python3 sleep.py

    root@Omega-745F:~# free
    total used free shared buffers cached
    Mem: 124808 56536 68272 92 15988 18952

    root@Omega-745F:~# micropython sleep.py &

    root@Omega-745F:~# free
    total used free shared buffers cached
    Mem: 124808 56660 68148 92 15988 18952

    root@Omega-745F:~# ps
    1995 root 2600 S micropython sleep.py

    Thanks..



  • @tjoseph1 Why not just call the c library functions directly.



  • @crispyoz :

    Why not just call the c library functions directly.

    From python3/micropython, how to do that ?

    Thanks..



  • @tjoseph1 There are some docs/discussions for calling musl libc using micropython, just google it. Another approach would be to write a micropython specific c function that calls libc functionality.

    Just another reason to dislike python šŸ™‚



  • @crispyoz :

    Thanks ..
    The solutions I found were using ffilib, ctypes or mpy.
    mpy is not implemented in 1.9.2 ?
    >>> import sys
    >>> sys.implementation
    (name='micropython', version=(1, 9, 2))

    but could find it 1.13.0, the latest.
    >>> import sys
    >>> sys.implementation
    (name='micropython', version=(1, 13, 0), mpy=9733)

    Don't you think, those are much of an overhead for py programmer ?
    The approaches are different.
    py programmer: how do I get this done?
    c programmer: how do I get the system to do this?

    Just another reason to dislike python people who do not tell other py programmers-that python is NOT for everything šŸ™‚



  • @tjoseph1 yes a 4GL in fancy clothing šŸ™‚



  • @crispyoz :
    May be they (the py lib people - they must be hardcore c programmers as well) are constrained, and are going by the 80/20 rule.. 80% of the time, the implemented 20% feature works..

    Agian, on a non-constrained platform python works well.. to make all happy.



  • @tjoseph1 You don't want to start me on this šŸ™‚



  • @crispyoz :
    I am here to listen.. and I am sure that it will broaden my outlook..
    As an eg., you got me search that gave me 3 options today..

    I genaralize, based on what I know..

    So, please..go ahead šŸ™‚


Log in to reply
 

Looks like your connection to Community was lost, please wait while we try to reconnect.