Post Go back to editing

I can't launch adis16507_example.py of the pyadi-iio project

Category: Software
Product Number: adis16507-1
Software Version: pyadi-iio

Hello,

I want to launch the example adis16507_example.py of the  pyadi-iio project on my raspberry pi 4.

However, I have errors on which I stumbled for a while.

$  python3 adis16507_example.py
 
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/dist-packages/adi/context_manager.py", line 65, in __init__
    self._ctx = iio.Context(self.uri)
  File "/usr/local/lib/python3.10/dist-packages/iio.py", line 1358, in __init__
    self._context = _new_uri(_context.encode("ascii"))
  File "/usr/local/lib/python3.10/dist-packages/iio.py", line 56, in _check_null
    raise OSError(err, _strerror(err))
OSError: [Errno 6] No such device or address

During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/home/pi/pyadi-iio/examples/adis16507_example.py", line 39, in <module>
    imu = adi.adis16507(uri="ip:analog")
  File "/usr/local/lib/python3.10/dist-packages/adi/adis16507.py", line 59, in __init__
    context_manager.__init__(self, uri, self._device_name)
  File "/usr/local/lib/python3.10/dist-packages/adi/context_manager.py", line 67, in __init__
    raise Exception("No device found")
Exception: No device found

My sensor is well connected and functional because I can read the values of the sensor:

$ cat /sys/bus/iio/devices/iio\:device0/in_anglvel_z_raw

-3819836

Do you have an idea?

Thanks in advance.

Dimitri Sigg

  • Are you running Kuiper Linux or something else? If something else do you have iiod running?

    -Travis

  • I'm working on a Raspberry pi4 with Ubuntu 22.04 on which I have plugged my imu.

    $ uname -a
    
    Linux ubuntu 5.15.0-1016-raspi #18-Ubuntu SMP PREEMPT Wed Sep 28 12:15:55 UTC 2022 aarch64 aarch64 aarch64 GNU/Linux

    I have nothing else connected.

    Here is the version of iiod that I have:

    $ iiod -V
    
    0.24

    However I am a beginner. Is there a step to do with iiod before launching the .py with python?

  • iiod needs to be running if you want to use the IP context which the demo defaults to.  So you can:

    1. Change the context from ip:analog to local:

    2. Start iiod before running the example.

    -Travis

  • Thanks for your advice.

    I launch iiod this way:

    $ iiod
    
    Starting IIO Daemon version 0.24.cee2d136
    IPv6 support enabled
    Attempting to start Avahi
    ERROR: host ubuntu
    Avahi: Started.

    Then I run python3 adis16507_example.py in uri="local"

    Traceback (most recent call last):
      File "/usr/local/lib/python3.10/dist-packages/pyadi_iio-0.0.14-py3.10.egg/adi/context_manager.py", line 65, in __init__
      File "/usr/local/lib/python3.10/dist-packages/pylibiio-0.23.1-py3.10.egg/iio.py", line 1358, in __init__
        self._context = _new_uri(_context.encode("ascii"))
      File "/usr/local/lib/python3.10/dist-packages/pylibiio-0.23.1-py3.10.egg/iio.py", line 56, in _check_null
        raise OSError(err, _strerror(err))
    OSError: [Errno 38] Function not implemented
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "/home/pi/pyadi-iio/examples/adis16507_example.py", line 40, in <module>
        imu = adi.adis16507(uri="local")
      File "/usr/local/lib/python3.10/dist-packages/pyadi_iio-0.0.14-py3.10.egg/adi/adis16507.py", line 59, in __init__
      File "/usr/local/lib/python3.10/dist-packages/pyadi_iio-0.0.14-py3.10.egg/adi/context_manager.py", line 67, in __init__
    Exception: No device found

    The error changes slightly but it still doesn't work 

  • Sorry if I didn’t explain it better but I meant you could do one or the other. If you use the local context you don’t need iiod.

    However, if you want to run iiod I would recommend installing it as a service. See the CMake params here https://github.com/analogdevicesinc/libiio/blob/master/README_BUILD.md you probably want systemd with Ubuntu. For the local context you missed the colon. It should be local: and not local.

    -Travis

  • Okay, thanks, I got it. I used in my case the "local:" version 

    $ python3 adis16507_example.py
    
    Traceback (most recent call last):
      File "/home/pi/pyadi-iio/examples/adis16507_example.py", line 40, in <module>
        imu = adi.adis16507(uri="local:")
      File "/usr/local/lib/python3.10/dist-packages/pyadi_iio-0.0.14-py3.10.egg/adi/adis16507.py", line 65, in __init__
    AttributeError: 'NoneType' object has no attribute '_set_trigger'

    The error is different but I don't understand how to fix it.

    Thank you very much for your help.

  • The adis16507 class assumes certain driver names: https://github.com/analogdevicesinc/pyadi-iio/blob/master/adi/adis16507.py#L56

    If they are different on your platform you will need to update them. There is no real way for pyadi-iio to do this automatically since the driver names are arbitrary,

    -Travis

  • Yes, I did pay attention to that. I put the following names:

    cat /sys/bus/iio/devices/iio\:device0/name
    
    adis16507-1

    $ cat /sys/bus/iio/devices/trigger0/name
    
    adis16507-1-dev0
    
    

    So my file /pyadi-iio/adi/adis16507.py:

            self, uri="", imu_dev_name="adis16507-1", trigger_name="adis16507-1-dev0"

  • Are you still getting the error? The error "AttributeError: 'NoneType' object has no attribute '_set_trigger'" basically means it cannot find the related device "adis16507-1". If this is still the case can you run in python:

    import iio
    
    ctx = iio.Context("local:")
    
    dev = ctx.find_device("adis16507-1")
    
    assert dev
    
    for chan in dev.channels:
        print(chan.id)
    
    

    -Travis

  • I ran it and it works without error:

    $ python3 test
    accel_x
    accel_y
    accel_z
    anglvel_x
    anglvel_y
    anglvel_z
    temp0
    timestamp