intrepidcs / python_ics

Library for interfacing with Intrepid devices in Python
MIT License
61 stars 29 forks source link

RAD-Moon 2: fails to open with libicsneo on linux #162

Closed jacobschaer closed 6 months ago

jacobschaer commented 10 months ago

I need to be able to control some settings on a radmoon programatically and was hoping to be able to do it with Python-ICS API. I was able to get what I need on Windows, but not on Linux. Issue was confirmed by support and is supposedly due to a discrepancy between icsneo40.dll and libicsneo capabilities.

On Windows:

Install ICS Hardware Installation Kit: https://cdn.intrepidcs.net/updates/files/RP1210KitInstall.zip
Install python-ics python package
    pip install python-ics
    pip freeze
        python-ics==912.4post1
In python I can
    import ics
    ics.FindNeoDevices()
    (<ics.ics.NeoDevice RAD-Moon 2 RM5913>,)
    device = ics.open_device(ics.FindNeoDevices()[0])

This is fine.

On Ubuntu 18.04 and Ubuntu 23 with Python 3.8 and 3.11, the first command (FindNeoDevices()) enumerates the device properly but attempts to call open_device() fail with

ics.ics.RuntimeError: Error: open_device(): icsneoOpenDevice() Failed

I tried with the supplied libicsneolegacy.so as well as compiled from source for python-ics=910.10.post6 - same result.

I tried running as root and ensured I had installed the 99-instrepidcs.rules

drebbe-intrepid commented 10 months ago

@jacobschaer If you run this script as root does it work? This would point to the rules not being applied correctly.

edit: Its possible the supplied libicsneolegacy with 910 doesn't work. PIP broke updating to latest release, old versions can't install newer versions. I don't remember the version cut off for that.

jacobschaer commented 10 months ago

Thanks for the reply.

It didn't work correctly as root either. As I recall, if I ran without root and without the rules it wouldn't even enumerate the device but not 100% sure.

If you have a recommended way to work around the pip issues or can supply a test wheel/sdist zip I can try it when I get back in a week. I do remember fighting PIP a lot on the latest.

jacobschaer commented 9 months ago

Any ideas on what PIP version to use? I'm happy to try a dev build or something.

drebbe-intrepid commented 9 months ago

@jacobschaer Sorry, I failed at replying to your last comment. I haven't found any official documentation on why old versions of PIP can't install latest. Seems like it wasn't really documented very well.

From what I can tell version 22.1 of PIP should certainly work always. What ships with Debian 12 and latest LTS of Ubuntu 22.04 "should" also work, older releases of these two distributions probably won't install latest.

drebbe-intrepid commented 9 months ago

I've confirmed internally that latest isn't working.

python_ics is on https://github.com/intrepidcs/libicsneo/commit/9ef93eb73e1ada72ccc7a571744b9db1a564f18b and we need to be on at least https://github.com/intrepidcs/libicsneo/commit/6c93fc839b42213f989efb7a04a104962cdd07b2

I'll try to get the packages updated today and confirm RAD-Moon2 is working for you. Sorry for the issues here.

edit: All libicsneo version are non-functional and not working currently with RAD-Moon2. libicsneolegacy attempts to go online when we open and RAD-Moon2 can not do this. We missed this in testing because we were using RAD-Supermoons. I'll ping here as soon as I have an update/fix for you.

drebbe-intrepid commented 9 months ago

Internal issue 152 for tracking purposes.

jacobschaer commented 6 months ago

Any updates on this issue?

drebbe-intrepid commented 6 months ago

@jacobschaer This is in progress right now. There should be a fix coming shortly. Thanks for your patience with this matter so far.

subrivian commented 6 months ago

Can you explain to me what I need to do to use these updates?

On Ubuntu 22.04:

  1. sudo apt-get install flex bison clang
  2. python3.8 -m venv venv
  3. source venv/bin/activate
  4. git clone https://github.com/intrepidcs/python_ics
  5. cd python_ics
  6. git submodule update --init
  7. python -m pip install .
  8. python radmoon.py

Traceback (most recent call last): File "radmoon.py", line 68, in devices = ics.FindNeoDevices() ics.ics.RuntimeError: Error: find_devices(): Failed to Retrieve address of function 'icsneoFindDevices': {...}/venv/lib/python3.8/site-packages/ics/ics.cpython-38-x86_64-linux-gnu.so: undefined symbol: icsneoFindDevices for library '${ORIGIN}/libicsneolegacy.so'

I tried just pip install python_ics and it offered an older version

drebbe-intrepid commented 6 months ago

@subrivian I've reproduced this locally. Looking into it now. Master is currently broke.

>>> ics.override_library_name(r'/home/drebbe/dev/python_ics/.venv/lib/python3.11/site-packages/ics/libicsneolegacy.so')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ics.ics.RuntimeError: Error: override_library_name(): Failed to open library '/home/drebbe/dev/python_ics/.venv/lib/python3.11/site-packages/ics/libicsneolegacy.so': /home/drebbe/dev/python_ics/.venv/lib/python3.11/site-packages/ics/libicsneolegacy.so: undefined symbol: dbus_connection_read_write
subrivian commented 6 months ago

What's interesting is it works fine if I used the wheel from the github build artifacts for the MR you linked. So, hopefully once you do a release to PyPi this will be a non-issue but would be nice to be able to build locally and get a workign package. Thanks

drebbe-intrepid commented 6 months ago

@subrivian This issue should be resolved now. I was able to fix it locally on my machine.

@jacobschaer RAD-Moon2 should work now. I'll be providing an official release to PIP hopefully soon but you can always grab the artifacts / wheels for now if needed right away.

drebbe-intrepid commented 6 months ago

Closing this issue as complete, please feel free to re-open this if there is still an issue. latest version on PyPI should be functional.