Python automation script

Hi, I’m in the process of building the framework for collecting data from Joulescope. I tried to use the example scripts that you have posted but ran into this issue. I’m using linux Ubuntu OS and Joulescope is connected with USB port. Below is my issue. Can you please give me a pointer where I should look at first? Thank you.

File “capture_simple.py”, line 33, in
run()
File “capture_simple.py”, line 24, in run
device = scan_require_one(config=‘usb’)
File “/home/lab/.local/lib/python3.6/site-packages/joulescope/driver.py”, line 1118, in scan_require_one
raise RuntimeError(“no devices found”)
RuntimeError: no devices found

1 Like

Hi @atmosic and welcome to the forum! With linux, you first need to ensure that you have proper permissions to access the device. Check out this discussion.

You need to issue two commands:

$ lsusb -d 16d0:0e88
$ ls -al /dev/bus/usb/{bus}/{device}

Replacing {bus} and {device} with the values returned by lsusb. On my system, I see:

$ lsusb -d 16d0:0e88
Bus 002 Device 021: ID 16d0:0e88 MCS
$ ls -al /dev/bus/usb/002/021
crw-rw-rw- 1 root root 189, 148 Jun 26 19:07 /dev/bus/usb/002/021

If you don’t have sufficient permissions, you need to add a udev rule.

It looks like libusb was found, but just in case also do this:

sudo apt install libusb-1.0-0-dev

You should then be able to install the joulescope package (which you probably already have done):

pip3 install joulescope

Then try:

python3 -m joulescope gpo_demo

Here is the expected output:

INFO:joulescope.usb.libusb.device:scan found ['16d0/0e88/000416']
INFO:joulescope.usb.device_thread:open
INFO:joulescope.usb.device_thread:DeviceThread.run start
INFO:joulescope.usb.libusb.device:close
INFO:joulescope.usb.libusb.device:open: start 16d0/0e88/000416
INFO:joulescope.usb.libusb.device:open: success
INFO:joulescope.usb.libusb.device:open: configure device
INFO:joulescope.usb.libusb.device:open: done
INFO:joulescope.driver:info:
{
  "type": "info",
  "ver": 1,
  "ctl": {
    "mfg": {
      "country": "USA",
      "location": "MD_01",
      "lot": "201927_00"
    },
    "hw": {
      "rev": "H",
      "sn_mcu": "820A303182C45FAA8EE51A954091005F",
      "sn_mfg": "000416"
    },
    "fw": {
      "ver": "1.1.0"
    },
    "fpga": {
      "ver": "0.2.0",
      "prod_id": "0x9314acf2"
    }
  },
  "sensor": {}
}
INFO:joulescope.driver:serial number = 28a00313284cf5aae85ea159041900f5
INFO:joulescope.driver:stop : streaming=False
INFO:joulescope.usb.device_thread:close
INFO:joulescope.usb.libusb.device:close
INFO:joulescope.usb.libusb.device:ControlTransferAsync.close 0
INFO:joulescope.usb.device_thread:DeviceThread._cmd_process_all close
INFO:joulescope.usb.device_thread:DeviceThread.run flush
INFO:joulescope.usb.device_thread:DeviceThread.run done

Please post with what you see on your machine. Thanks!

Hi mliberty, the steps are right on the dot. it works for me now. thanks.

1 Like