Multi Instrument Moku Pro in Python Connections don't work

Hello,
I am trying the code on your website for the Multi-Instrument Moku-Pro. However, it keeps giving an error about the connections. I think it is related to the connections inside, between the wavegenerator and the oscilloscope. The error I am getting is the following:
[{‘destination’: ‘Slot1InA’, ‘source’: ‘Input1’}, {‘destination’: ‘Slot2InA’, ‘source’: ‘Slot1OutA’}, {‘destination’: ‘Slot2InB’, ‘source’: ‘Slot1OutA’}, {‘destination’: ‘Slot2InC’, ‘source’: ‘Slot1OutB’}, {‘destination’: ‘Slot2InD’, ‘source’: ‘Slot1OutB’}, {‘destination’: ‘Output1’, ‘source’: ‘Slot2OutA’}]
Exception occurred: [‘Cannot understand request. One or more key/values are incorrect’]

I tried changing and playing with the connections part but it doesn’t work. The code I am using is directly from your website, and it is this:

import matplotlib.pyplot as plt

from moku.instruments import MultiInstrument
from moku.instruments import Oscilloscope, WaveformGenerator

m = MultiInstrument(‘172.16.13.195’, platform_id=4, force_connect=True)
try:
wg = m.set_instrument(1, WaveformGenerator)
osc = m.set_instrument(2, Oscilloscope)

connections = [dict(source="Input1", destination="Slot1InA"),
               dict(source="Slot1OutA", destination="Slot2InA"),
               dict(source="Slot1OutA", destination="Slot2InB"),
               dict(source="Slot2OutA", destination="Output1")
               ]



print(m.set_connections(connections=connections))

wg.generate_waveform(1, "Sine")
osc.set_timebase(-5e-3, 5e-3)
data = osc.get_data()

# Set up the plotting parameters
plt.ion()
plt.show()
plt.grid(visible=True)
plt.ylim([-1, 1])
plt.xlim([data['time'][0], data['time'][-1]])

line1, = plt.plot([])
line2, = plt.plot([])

# Configure labels for axes
ax = plt.gca()

# This loops continuously updates the plot with new data
while True:
    # Get new data
    data = osc.get_data()

    # Update the plot
    line1.set_ydata(data['ch1'])
    line2.set_ydata(data['ch2'])
    line1.set_xdata(data['time'])
    line2.set_xdata(data['time'])
    plt.pause(0.001)

except Exception as e:
print(f’Exception occurred: {e}')
finally:
# Close the connection to the Moku device
# This ensures network resources and released correctly
m.relinquish_ownership()

Hi ecekbb,

The code you’ve provided works for me without errors, are you able to tell me which version of the API and firmware you are using?

You can test your firmware version on the app or using mokucli list and the API version you have with the command pip show moku.

Let me know how you go,
Indira

Hi indira,
I get the following:

Name Serial HW FW IP

MokuPro-000311 311 Pro 600 fe80::7269:79ff:feb0:540%11

and
Name: moku
Version: 3.3.3

I believe they are up to date. I then figured out the problem was not with the connections but with the oscillator. Because when I try to use your python code for the oscillator only, that gives the same error. Do you have any idea?
Thank you for your help,
Ece

Thanks Ece,

If you download the latest Firmware that should fix your problem. I believe what is happening is that in the recent firmware and API updates there has been a variable name change (frame_length is now max_length) and because you have mismatched versions that you have between your API Package and the Firmware it cannot understand the request you’re making as it is expecting the new max_length term, which is always implicitly set in the Oscilloscope.

You can download the latest Firmware to your device via the latest version of our App which is downloadable from our website, or upgrade from the top right of the current version of your App (the bell notification). After updating the Firmware on your device you should be able to run this code without errors.

Let me know how the Firmware update is successful,
Indira