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
  • Hi 

    I am able to see the USB address in the Scopy and do not have issue connecting with the ip address in the python binding.

    Can you please explain how I can see the ip address and not the usb address from the same USB cable? It is weird explanation.

    Yes, I do see the M2K inside the device manager.

Children