ADALM1000 python Linux libsmu 2019

Hello

I try to use Adalm 1000 with simple python command under Linux ubuntu 18.04
I follow python tutorial:
https://wiki.analog.com/university/tools/python-tutorial/table-of-contents

I try to found the required files :
pysmu.py and libpysmu.so  :no more available, not found in :
https://github.com/analogdevicesinc/libsmu

I follow libsmu installation and building in previous link. No error.
I start simple example found here:
https://wiki.analog.com/_media/university/tools/python-tutorial/alm1000_tutorial.zip

<python blink_led.py
    session = Session(ignore_dataflow=True, queue_size=10000)
NameError: name 'Session' is not defined

lsusb and dmesg show adalm1000 module
I miss something in libsmu installation. Link? Path? usr?? Thanks for help


tagged
[edited by: JValeriani at 4:51 PM (GMT 0) on 3 Oct 2019]
Parents Reply
  • 0
    •  Analog Employees 
    on Nov 4, 2019 1:04 PM 11 months ago in reply to remis73

    Hi,

    You need to rebuild libsmu in order to build/link it against Python3.
    Also, we need to force CMake to check Python3 instead of Python2. The instructions are the following (Please modify them to use your exact paths to the Python3 version you have installed. This example uses 3.6)

    sudo apt-get install python3-setuptools python3-pip
    sudo pip3 install cython

    cd libsmu
    mkdir build_py3 && cd build_py3
    cmake -DPYTHON_EXECUTABLE=/usr/bin/python3 -DPYTHON_INCLUDE_DIR=/usr/include/python3.6m -DPYTHON_LIBRARY=/usr/lib/x86_64-linux-gnu/libpython3.6m.so ..
    make
    sudo make install
    export PYTHONPATH=/usr/lib/python3.6/site-packages:${PYTHONPATH}


    -Alexandra

     

Children
  • Hello,

    I follow your commands : compilation is ok , no error message. I try on two differents PC with linux : same result , same error message : NameError: name 'Session' is not defined . even with smu -l confirming the adalm1000 board.

  • 0
    •  Analog Employees 
    on Nov 8, 2019 2:56 PM 11 months ago in reply to remis73

    Hi,

    Can you send us a simple example script that you run and get this error, so we can test it?

    -Alexandra

  • Hello Alexandra,

    smu -l
    ADALM1000: serial 2031205051485435313330303530323 : fw 2.16 : hw F

    python3 blink_led.py
    Traceback (most recent call last):
    File "blink_led.py", line 41, in <module>
    session = Session(ignore_dataflow=True, queue_size=10000)
    NameError: name 'Session' is not defined

    Here is the code :

    ***************************************

    #!/usr/bin/python
    #For Python version > = 2.7.8
    from tkinter import *
    import atexit
    from collections import defaultdict
    from operator import add
    import time
    from pysmu import *


    # define button actions
    def Digital_out():
    global PIO_0, PIO_1, PIO_2, PIO_3
    while (True): # Main loop
    if (RUNstatus.get() == 1):
    devx.ctrl_transfer(0x40, 0x50, PIO_0, 0, 0, 0, 100) # set to 0
    devx.ctrl_transfer(0x40, 0x50, PIO_1, 0, 0, 0, 100)
    devx.ctrl_transfer(0x40, 0x50, PIO_2, 0, 0, 0, 100)
    devx.ctrl_transfer(0x40, 0x50, PIO_3, 0, 0, 0, 100)
    time.sleep(0.1)
    devx.ctrl_transfer(0x40, 0x51, PIO_0, 0, 0, 0, 100) # set to 1
    time.sleep(0.1)
    devx.ctrl_transfer(0x40, 0x51, PIO_1, 0, 0, 0, 100)
    time.sleep(0.1)
    devx.ctrl_transfer(0x40, 0x51, PIO_2, 0, 0, 0, 100)
    time.sleep(0.1)
    devx.ctrl_transfer(0x40, 0x51, PIO_3, 0, 0, 0, 100)
    time.sleep(0.1)
    devx.ctrl_transfer(0x40, 0x50, PIO_0, 0, 0, 0, 100) # set to 0
    time.sleep(0.1)
    devx.ctrl_transfer(0x40, 0x50, PIO_1, 0, 0, 0, 100)
    time.sleep(0.1)
    devx.ctrl_transfer(0x40, 0x50, PIO_2, 0, 0, 0, 100)
    time.sleep(0.1)
    devx.ctrl_transfer(0x40, 0x50, PIO_3, 0, 0, 0, 100)
    # Update tasks and screens by TKinter
    root.update_idletasks()
    root.update()

    # Setup ADAML1000
    session = Session(ignore_dataflow=True, queue_size=10000)
    if not session.devices:
    print ('no device found')
    root.destroy()
    exit()
    #
    devx = session.devices[0]
    # assign digital pins
    PIO_0 = 28
    PIO_1 = 29
    PIO_2 = 47
    PIO_3 = 3
    # setup main window
    root = Tk()

    label = Label(root)
    label.grid(row=1, columnspan=1, sticky=W)
    label.config(text = "Blink LEDs")
    RUNstatus = IntVar(0)
    rb1 = Radiobutton(root, text="Stop", variable=RUNstatus, value=0 )
    rb1.grid(row=2, column=0, sticky=W)
    rb2 = Radiobutton(root, text="Run", variable=RUNstatus, value=1 )
    rb2.grid(row=2, column=1, sticky=W)

    # start main loop
    root.update()
    # Start sampling
    Digital_out()
    # root.mainloop()

  • 0
    •  Analog Employees 
    on Nov 12, 2019 6:07 PM 11 months ago in reply to remis73

    To get that version of the program to run with Python 3.7 two lines need to be edited:

    from tkinter import *

    Module name changed from 2.7 to 3.7

    print('no device found')

    Need to add () for print statement

    Once these are changed it runs as expected in Python 3.7 ( Windows 10, libsmu master )

    I have no idea why your built version of libsmu does not recognize Session function. Are you absolutely sure you have removed any old previous versions of libsmu you might have compiled in the past and cloned the very latest from GitHub?

    Doug

  • Hello Doug,

    No i'm not absolutely sure... thus , could you confirm  the command to remove all libsmu versions?

    I will try a new compilation under 3.7  with last github https://github.com/analogdevicesinc/libsmu/blob/master/README.md

    Regards