Moku Datalogger python odd error

Moku model:
Moku:Go
Operating system:
Windows 10
Software version:
firmware version 580
python API

Bug or support request description:
I’m trying to use the datalogger on a Moku:Go via python. I’m using the example found here: Examples for Python | Moku API

With a non-modified version of said code (other than my Moku:Go’s IP) I kept getting an error about not being able to connect to a port (the port number itself kept changing), so I modified the code a bit so I could find out what exactly was wrong, as such:

#
# moku example: Basic Datalogger streaming
#
# This example demonstrates use of the Datalogger instrument to
# stream time-series voltage data and plot it using matplotlib
#
# (c) 2022 Liquid Instruments Pty. Ltd.
#
import matplotlib.pyplot as plt

from moku.instruments import Datalogger

i = Datalogger('[fe80::7269:79ff:feb9:2afe%10]', force_connect=False)
i.start_streaming(1)
i.get_stream_data()

try:
    # generate a waveform on output channel 1
    i.generate_waveform(1, "Sine", frequency=100)

    # disable Input2 as we want to stream data only from Input1
    i.disable_channel(2)

    # set the sample rate to 10KSa/s
    i.set_samplerate(10e3)

    # stream the data for 10 seconds..
    i.start_streaming(10)

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

    line1, = plt.plot([])

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

    # This loops continuously updates the plot with new data
    while True:
        # get the chunk of streamed data
        print('here1')
        data = i.get_stream_data()
        print('here2')
        if data:
            plt.xlim([data['time'][0], data['time'][-1]])
            # Update the plot
            line1.set_ydata(data['ch1'])
            line1.set_xdata(data['time'])
            plt.pause(0.001)

except Exception as e:
    i.stop_streaming()
    print(e)
finally:
    i.relinquish_ownership()

This code gives me an error of:

  File ~\Anaconda3\lib\site-packages\moku\instruments\_stream.py:72 in _connect
    client.connect(("localhost", self.port))

ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it


During handling of the above exception, another exception occurred:

Traceback (most recent call last):

  File ~\untitled0.py:15 in <module>
    i.get_stream_data()

  File ~\Anaconda3\lib\site-packages\moku\instruments\_stream.py:132 in get_stream_data
    self._begin_streaming()

  File ~\Anaconda3\lib\site-packages\moku\instruments\_stream.py:93 in _begin_streaming
    self._connect()

  File ~\Anaconda3\lib\site-packages\moku\instruments\_stream.py:77 in _connect
    raise Exception(f"Cannot connect to port {self.port}")

Exception: Cannot connect to port 52406

I have not been able to find any documentation online relating to this error and the moku API. What am I doing incorrectly?

This error is due to an issue with streaming over IPv6 (USBC) and is actually being fixed very soon. The update will involve a new version of the Moku CLI which we will announce is available in the next few days.

Also, looking at your code, the IPv6 address looks strange. Was this copied directly from the Moku app or somewhere else?

I obtained this IPv6 address by going to the anaconda terminal, entering “moku list” and taking the address listed there. I am glad to hear that this issue will be fixed, thank you so much.