moku.exceptions.MokuException: Unknown exception. Status code:502

Hello,

I am using the Moku Pro in the multi-instrument mode. The setup is fairly simple, all inputs are assigned to oscilloscopes and two outputs are assigned to the arbitrary waveform generator. A binary sequence is generated by the waveform generator and the output is looped back into the oscilloscope by an external cable.

The setup can be loaded via the Python API into the Moku. Loading is not an issue as I can independently verify the generated output sequence via an external oscilloscope. The Moku oscilloscope is also working correctly, I can verify this using the iPad app when I terminate the Python connection.

The error “moku.exceptions.MokuException: Unknown exception. Status code:502” occurs when I try to improve the resolution of the Oscilloscope data by running the following command:

  • mokuPro.set_timebase(-5e-7, 5e-7)

The error does not occur when I select t1 and t2 units below 5e6, but any higher resolution results in a loss of ethernet packets.

I have confirmed that the Moku is configured with the correct timebase values via the iPad app, but the same cannot be tested through the Python API.

The Moku is updated to the latest available version of the firmware.

Your assistance will be greatly appreciated.

Thanks
Alan

Hey Alan, thanks for posting this error. Could you tell me how you are acquiring your Moku:Pro’s IP address to be used in python? The 502 error is generally related to server errors so the set_timebase() function shouldn’t have any effect. Be sure you are using the IP address given in the Desktop app or iPad app and not the one from ‘moku list’ as this can sometimes return a different address than the one used for connecting to the API server.

Could you also check that you have the latest instrument files downloaded for the moku-python package? You can do this by running

moku download --fw_ver=574

Please let me know if this issue persists after checking the above.

Hi Sam, thanks for looking into this issue.

I am not using ‘moku list’ to identify the MokuPro’s IP address. I have manually set the IP address on the MokuPro, via the desktop app, and I can confirm that it works.
I am also running the latest version of the moku-python package, I ran the command you suggested and got a “Moku Client Version 2.5.1. Instruments already up to date for firmwareversion 574.” message.

As far as I can see I am able to control all moku functions with the exception of the Oscilloscope resolution in multi-instrument mode (high resolution, low seems to work fine). I agree that a drop in network connection shouldn’t be associated with the set_timebase() function, but that’s what’s happening in my case. Could it be that the moku is trying to send too many packets back and the network adapter is crashing? What is the maximum data throughput the moku can achieve over gigabit ethernet?

Thaks
Alan

Here is the debug information:

Traceback (most recent call last):
File “…testArbitraryWaveform.py”, line 148, in
raise e
File “…testArbitraryWaveform.py”, line 102, in
receivedData2 = mokuProScopeNo2.get_data()
File “…PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\moku\instruments_oscilloscope.py”, line 529, in get_data
return self.session.post(
File “…PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\moku\session.py”, line 14, in func_wrapper
return self.resolve(response)
File “…PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\moku\session.py”, line 143, in resolve
self.handle_http_error(response)
File “…PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\moku\session.py”, line 86, in handle_http_error
raise exceptions.MokuException(
moku.exceptions.MokuException: Unknown exception. Status code:504

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “…testArbitraryWaveform.py”, line 152, in
mokuPro.relinquish_ownership()
File “…PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\moku_init_.py”, line 119, in relinquish_ownership
return self.session.post(“moku”, operation)
File “…PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\moku\session.py”, line 14, in func_wrapper
return self.resolve(response)
File “…PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\moku\session.py”, line 143, in resolve
self.handle_http_error(response)
File “…PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\moku\session.py”, line 86, in handle_http_error
raise exceptions.MokuException(
moku.exceptions.MokuException: Unknown exception. Status code:502

Thank you for confirming the instrument firmware version and IP. The way that the Moku API server handles data packet transfer over the internet doesn’t change based on set_timebase() either. When you call get_data(), it will return 1024 points per channel no matter what the sampling rate is set to, which is strange why certain timebase settings do not work.

Would it be possible for you to share snippets of your code, specifically the parts where you set up the instrument and especially where you have called get_data()?

Thanks for a quick response.
Here is the main body of code I am using to connect to the Moku (it is largely based on the API examples on your website):

mokuPro = MultiInstrument(ip_addr, platform_id=4, force_connect=True)
try:
mokuProScopeNo1 = mokuPro.set_instrument(1, Oscilloscope)
mokuProScopeNo2 = mokuPro.set_instrument(2, Oscilloscope)
mokuProSigGen = mokuPro.set_instrument(3, ArbitraryWaveformGenerator)

connections =   [
                dict(source="Input1", destination="Slot1InA"),
                dict(source="Input2", destination="Slot1InB"),
                dict(source="Input3", destination="Slot2InA"),
                dict(source="Input4", destination="Slot2InB"),
                dict(source="Slot3OutA", destination="Output1"),
                dict(source="Slot3OutB", destination="Output2")
                ]
print(mokuPro.set_connections(connections=connections))


# Scope settings
time_slice = 0.5e-6 # WARNING: AT PRESENT DOES NOT WORK AT HIGHER RESOLUTION
min_view = -time_slice
max_view = time_slice
impedance_view = "50Ohm"
coupling_view = "DC"
attenuation_view = "0dB"

mokuPro.set_frontend(1, impedance_view, coupling_view, attenuation_view)
mokuPro.set_frontend(2, impedance_view, coupling_view, attenuation_view)
mokuPro.set_frontend(3, impedance_view, coupling_view, attenuation_view)
mokuPro.set_frontend(4, impedance_view, coupling_view, attenuation_view)

mokuProScopeNo1.enable_rollmode(roll=False)
mokuProScopeNo2.enable_rollmode(roll=False)

mokuProScopeNo1.set_timebase(min_view, max_view, False)
mokuProScopeNo2.set_timebase(min_view, max_view, False)

print("Scope No1", mokuProScopeNo1.get_frontend(2))
print("Scope No2", mokuProScopeNo2.get_frontend(1))


# Signal generator
mokuProSigGen.generate_waveform(channel=1,
                                sample_rate='Auto',
                                lut_data=list(file_input),
                                frequency=frequency,
                                amplitude=amplitude)
mokuProSigGen.generate_waveform(channel=2,
                                sample_rate='1.25Gs',
                                lut_data=list(file_input),
                                frequency=frequency,
                                amplitude=amplitude)

print("Signal Gen", mokuProSigGen.summary())


# Oscilloscope capture module No. 1
receivedData1 = mokuProScopeNo1.get_data()


# Oscilloscope capture module No. 2
receivedData2 = mokuProScopeNo2.get_data()

Hey Alan, I just wanted to give you an update that our API team is taking a look into this bug right now. Please allow them a few days to work on this as they are also getting things ready for the next release at the end of January. I will respond here once I have an update for you. Thanks for reporting this and for your patience while we figure it out!

BTW - it is an issue with having multiple oscilloscopes deployed on the APIs MiM configuration (the error doesn’t occur with only one scope deployed) and you are correct about the timebase being the cause. Thank you for providing the code an information for us to debug.

Hi Sam,

Thanks for looking into this issue!

I have tested my setup with one Oscilloscope (two channels), and it works as you suggested. I can now proceed with my experiment although I will need to use all the Oscilloscope inputs in the near future.
I appreciate your effort in this matter.

All the best.
Alan

What is the update on this issue?

I also got the same error: MokuException: Unknown exception. Status code:502
when using the Moku:pro multi-instruments with python API and using the waveform generator and two LockInAmplifier.