Python API with MacOS 11.0 not working

Hello,
The Joulescope UI has been working great, but I’m trying to get python automation going. I’m on
Python 3.9.10 (main, Jan 15 2022, 11:48:00)
[Clang 13.0.0 (clang-1300.0.29.3)]

and installed pyjls and joulescope after some issues. When I run joulescope capture_usb, here’s part of the error I’m facing:
ERROR:2022-03-09 12:10:46,737:device.py:819:joulescope.usb.libusb.device:open failed: 16d0/0e88/002038
Traceback (most recent call last):
OSError: libusb_set_configuration 1 failed [-4]
OSError: usb.Device ControlTransferResponse(result=5)
AttributeError: ‘joulescope.pattern_buffer.PatternBuffer’ object has no attribute ‘callback’

Hi @soccerismyblood and welcome to the Joulescope forum!

We should probably remove the joulescope capture_usb command as it’s really only useful for Joulescope development. It works under Windows, but I am not sure about Linux and macOS.

You probably want to use joulescope capture instead which captures a JLS v1 file. Does running this command work for you?

joulescope capture --duration 3 out.jls

Appreciate the immediate response! Still seeing a libusb error

pyjoulescope_examples-master % joulescope capture --duration 3 out.jls
WARNING:2022-03-09 13:04:51,781:device.py:749:joulescope.usb.libusb.device:libusb_set_configuration 1 failed [-4]
ERROR:2022-03-09 13:04:51,781:device.py:819:joulescope.usb.libusb.device:open failed: 16d0/0e88/002038
Traceback (most recent call last):
File “/usr/local/lib/python3.9/site-packages/joulescope/usb/libusb/device.py”, line 811, in open
may_raise_ioerror(rv, ‘libusb_set_configuration 1 failed’)
File “/usr/local/lib/python3.9/site-packages/joulescope/usb/libusb/device.py”, line 750, in may_raise_ioerror
raise IOError(s)
OSError: libusb_set_configuration 1 failed [-4]
ERROR:2022-03-09 13:04:51,784:device_thread.py:86:joulescope.usb.device_thread:While running command
Traceback (most recent call last):
File “/usr/local/lib/python3.9/site-packages/joulescope/usb/device_thread.py”, line 64, in _cmd_process
rv = self._device.open(event_callback_fn)
File “/usr/local/lib/python3.9/site-packages/joulescope/usb/libusb/device.py”, line 811, in open
may_raise_ioerror(rv, ‘libusb_set_configuration 1 failed’)
File “/usr/local/lib/python3.9/site-packages/joulescope/usb/libusb/device.py”, line 750, in may_raise_ioerror
raise IOError(s)
OSError: libusb_set_configuration 1 failed [-4]
WARNING:2022-03-09 13:04:52,600:driver.py:499:joulescope.driver:usb control transfer failed 5
WARNING:2022-03-09 13:04:52,630:driver.py:615:joulescope.driver:calibration_read transfer failed 5
WARNING:2022-03-09 13:04:52,655:driver.py:568:joulescope.driver:could not set defaults
ERROR:2022-03-09 13:04:52,656:capture.py:104:root:while capturing data
Traceback (most recent call last):
File “/usr/local/lib/python3.9/site-packages/joulescope/entry_points/capture.py”, line 77, in run
recorder = DataRecorder(filename,
File “/usr/local/lib/python3.9/site-packages/joulescope/data_recorder.py”, line 122, in init
self._writer.append_subfile(‘calibration’, calibration)
File “/usr/local/lib/python3.9/site-packages/joulescope/datafile.py”, line 408, in append_subfile
payload = n + bytes([0] * (128 - len(n))) + data
TypeError: can’t concat NoneType to bytes
Data capture failed

Thank you for sending the error. The -4 is very strange which is ERROR_NO_DEVICE. Just to confirm, the Joulescope UI starts up and works correctly on this computer and USB port?

If so, could you post the output of joulescope info?

Yep, UI is working fine. I have the HW plugged directly into the Type-C port on my Mac with a Type-A to C dongle. Here’s the output:

%joulescope info
System information
Python: 3.9.10 (main, Jan 15 2022, 11:48:00)
[Clang 13.0.0 (clang-1300.0.29.3)]
Platform: macOS-11.0-x86_64-i386-64bit (darwin)
Processor: i386
executable: /usr/local/opt/python@3.9/bin/python3.9
frozen: False

joulescope version: 0.9.11
Found 1 connected Joulescope:
WARNING:2022-03-09 13:19:03,369:device.py:749:joulescope.usb.libusb.device:libusb_set_configuration 1 failed [-4]
ERROR:2022-03-09 13:19:03,370:device.py:819:joulescope.usb.libusb.device:open failed: 16d0/0e88/002038
Traceback (most recent call last):
File “/usr/local/lib/python3.9/site-packages/joulescope/usb/libusb/device.py”, line 811, in open
may_raise_ioerror(rv, ‘libusb_set_configuration 1 failed’)
File “/usr/local/lib/python3.9/site-packages/joulescope/usb/libusb/device.py”, line 750, in may_raise_ioerror
raise IOError(s)
OSError: libusb_set_configuration 1 failed [-4]
ERROR:2022-03-09 13:19:03,373:device_thread.py:86:joulescope.usb.device_thread:While running command
Traceback (most recent call last):
File “/usr/local/lib/python3.9/site-packages/joulescope/usb/device_thread.py”, line 64, in _cmd_process
rv = self._device.open(event_callback_fn)
File “/usr/local/lib/python3.9/site-packages/joulescope/usb/libusb/device.py”, line 811, in open
may_raise_ioerror(rv, ‘libusb_set_configuration 1 failed’)
File “/usr/local/lib/python3.9/site-packages/joulescope/usb/libusb/device.py”, line 750, in may_raise_ioerror
raise IOError(s)
OSError: libusb_set_configuration 1 failed [-4]
WARNING:2022-03-09 13:19:03,863:driver.py:499:joulescope.driver:usb control transfer failed 5
WARNING:2022-03-09 13:19:03,888:driver.py:615:joulescope.driver:calibration_read transfer failed 5
Joulescope:002038

whew… at least this isn’t an M1 issue. You don’t happen to have the Joulescope UI open and connected to the Joulescope, do you? Only one program can connect and open to the Joulescope at a time. If you do have the UI open, please close it and try the command line joulescope capture --duration 3 out.jls again.

You beat me to posting the comment. That was it! Works fine now. Thanks!

% joulescope info
System information
Python: 3.9.10 (main, Jan 15 2022, 11:48:00)
[Clang 13.0.0 (clang-1300.0.29.3)]
Platform: macOS-11.0-x86_64-i386-64bit (darwin)
Processor: i386
executable: /usr/local/opt/python@3.9/bin/python3.9
frozen: False

joulescope version: 0.9.11
Found 1 connected Joulescope:
Joulescope:002038 ctl=1.3.2 sensor=1.3.2

1 Like

Excellent! We really could do a lot better on that error message. Sorry that this issue took up your time, but great to hear that you are up and running!

1 Like