Js.read() function does not work

Just starting with my new JS220 working on win10 with Python 3.10
GUI example program works → JS220 and driver seem to be o.k.
But even example program form Joulescope homepage calling js.read() does not work:

import joulescope
import numpy as np
with joulescope.scan_require_one(config=‘auto’) as js:
data = js.read(contiguous_duration=0.1)
current, voltage = np.mean(data, axis=0, dtype=np.float64)
print(f’{current} A, {voltage} V’)

Always leads to the error:
Exception ignored in: ‘pyjoulescope_driver.binding._on_log_recv’
d_ctrl_req(2) returned 8
Exception ignored in: ‘pyjoulescope_driver.binding._on_log_recv’
d_ctrl_req(2) returned 8
Traceback (most recent call last):
File “C:\test\jsTest0001.txt”, line 4, in
data = js.read(contiguous_duration=0.1)
File “C:\Users\ToFToF\AppData\Local\Programs\Python\Python310\lib\site-packages\joulescope\v1\device.py”, line 509, in read
raise NotImplementedError() # todo
NotImplementedError

When looking into device.py:

def read(self, duration=None, contiguous_duration=None, out_format=None, fields=None):
“”"Read data from the device.

    :param duration: The duration in seconds for the capture.
        The duration must fit within the stream_buffer.
    :param contiguous_duration: The contiguous duration in seconds for
        the capture.  As opposed to duration, this ensures that the
        duration has no missing samples.  Missing samples usually
        occur when the device first starts.
        The duration must fit within the stream_buffer.
    :param out_format: The output format which is one of:

        * calibrated: The Nx2 np.ndarray(float32) with columns current and voltage.
        * raw: The raw Nx2 np.ndarray(uint16) Joulescope data.
        * samples_get: The StreamBuffer samples get format.  Use the fields
          parameter to optionally specify the signals to include.
        * None: equivalent to 'calibrated'.

    :param fields: The fields for samples_get when out_format=samples_get.

    If streaming was already in progress, it will be restarted.
    If neither duration or contiguous duration is specified, the capture
    will only be stopped by callbacks registered through
    :meth:`stream_process_register`.
    """
    raise NotImplementedError()  # todo

Is there really something missing or do I miss something?

Best regards

Hi @ToFToF and welcome to the Joulescope forum. Yes, it looks like we have not yet implemented read for the v1 backend. I’ll take a look at this today. In the meantime, you can try this:

python -m joulescope capture --duration 1.0 out.jls

But make sure that you update to the latest joulescope before as we just added duration late last week:

pip3 install -U joulescope pyjoulescope_driver

You can also check out capture.py and other examples.

The brand new 1.0.12 joulescope release (docs, changelog) now contains the read method.

You will need to upgrade to the latest:

pip3 install -U joulescope

Does the example now work for you?

I am deeply impressed about the quick response from you.

Yes, thank you, the example (and others) work now properly

1 Like