Post Go back to editing

Existing python code not working with python bindings of libm2k 0.80

Category: Software
Product Number: ADALM2000
Software Version: Libm2k 0.80

I have installed the libm2k 0.80 and its python bindings.

I have used python code with libm2k to communicate with ADALM2000 in the past. 

However, with recent installation, it seems that the existing python code does not work. I am not sure which was the last version that has worked with the existing code. 

The current issue is that it is not able to detect the ADALM2000 with the libm2k.getAllContexts() function. Let me know what has changed and 

# This is a sample Python script.

# Press Shift+F10 to execute it or replace it with your code.
# Press Double Shift to search everywhere for classes, files, tool windows, actions, and settings.

from sys import exit
import libm2k
import time
# import matplotlib.pyplot as plt
import bokeh
from bokeh.plotting import figure, output_file, show
from bokeh.models import LinearAxis, Range1d
from bokeh.models import HoverTool, BoxSelectTool #For enabling tools
import pandas as pd
import numpy as np
import struct
NB_OUT_SAMPLES = 1024


DIG_CH_SCLK = libm2k.DIO_CHANNEL_0
DIG_CH_MISO = libm2k.DIO_CHANNEL_1
DIG_CH_MOSI = libm2k.DIO_CHANNEL_2
DIG_CH_CSB = libm2k.DIO_CHANNEL_3
DIG_CH_BUSY = libm2k.DIO_CHANNEL_4
DIG_CH_TGP = libm2k.DIO_CHANNEL_5
DIG_CH_CONVST = libm2k.DIO_CHANNEL_6
DIG_CH_LDACB = libm2k.DIO_CHANNEL_7
DIG_CH_CMP = libm2k.DIO_CHANNEL_8
DIG_CH_RESETB = libm2k.DIO_CHANNEL_9
DIG_CH_ALERT = libm2k.DIO_CHANNEL_10
DIG_CH_TESTIN = libm2k.DIO_CHANNEL_11

ANALOG_IN_CH_0 = libm2k.ANALOG_IN_CHANNEL_1
ANALOG_IN_CH_1 = libm2k.ANALOG_IN_CHANNEL_2

POWER_PORT_0 = 0
POWER_PORT_1 = 1

BUFFER_SIZE = 10000
SAMPLES_PER_PERIOD = 16
OFFSET = 5

SAMPLING_FREQUENCY_IN = 1000000
SAMPLING_FREQUENCY_OUT = 10000
OVERSAMPLING = 1



def main():

    context_vec = libm2k.getAllContexts()
    if (len(context_vec) <= 0) :
        print('Connection Error: No ADALM2000 device available/connected to your PC.')
        exit(1)
        
    context = libm2k.m2kOpen(context_vec[0])
    # context = libm2k.m2kOpen('ip:192.168.2.1')
    if context is None:
        # context = libm2k.m2kOpen('usb:3.7.5')
        # context = libm2k.m2kOpen('usb:1.6.5')

        # if context is None:
        print('Connection Error: No ADALM2000 device available/connected to your PC.')
        exit(1)
        # else:
        #     print('ADALM2000 connected :' + context.getUri())
    else:
        print('ADALM2000 connected :' + context.getUri())

    # check if mixed signal is available on your firmware version
    if context.hasMixedSignal() is False:
        print("Mixed Signal not available")
        exit(1)

    context.calibrateADC()
    libm2k.contextClose(context, True)


# Press the green button in the gutter to run the script.
if __name__ == '__main__':
    main()

# See PyCharm help at https://www.jetbrains.com/help/pycharm/

Parents Reply Children
  • Hi 

    Can you please advise what should be the sequence of installations like libm2k, >> usb driver, >> any others, so that there are no issues.

  • There is no specific order for usb driver and libm2k installation since they are independent.
    from what I see your libiio supports usb connection only issue I can think of why it won't work is the cable used. 
    You can also try a clean install of the libm2k with the override option for libiio enabled .

  • Hello

    I have the following observations regarding USB detection issue.

    I am using the Dell docking station TB16. Scopy is able to detect the usb addess without any issue. Python binding is able to detect the ip address but not the usb address. and the get_all_contexts() function reveals nothing.

    However, I switched to WD19 Dell docking station of my colleague and this station is able to detect the usb address and ip address without any issues. Further the get_all_contexts() function is able to detect the device correctly.

  • Hello,
    Docking station connection is not reliable, is recommended to use direct connection if possible. 
    As mentioned here  " Some laptops limit the amount of current that can be delivered via an USB port (either default or from a docking station/usb hub)"

  • Hi 

    I believe there is no power delivery issue with it as Scopy can detect the USB address without any issue. It is something to do with parsing the address field that python binding is not able to handle. 

    Your recommendation is completely incorrect here.