I’m looking for a way to query if joulescope device is already open so I won’t get the error below.
“2024-08-15 16:53:10 ERROR open_ll but already open”
Code:
for device in dmms:
try:
device.active_device.open() # try to open resource
except:
pass
Hi @jj110 and welcome to the Joulescope forum! That logging error message comes from the joulescope_driver C backend. Although I don’t recommend it, you can disable all logging errors from this backend:
The CRITICAL level will filter and reject the ERROR log message.
The Joulescope API does not have a way to detect that the device is already open without just trying to open it. You could change the log level for just this call and restore it afterwards if you really want to do this.
In my experience, it is rarely the right choice to just open the first non-open Joulescope when you have multiple Joulescopes attached. You often want to open a specific Joulescope to make a measurement rather than hoping the one you want is the first non-open Joulescope. It’s usually much better to provide a filter based on serial number using some configuration method, such as a command-line argument. You can use the serial_number attribute to get the serial number before opening the device.
Hi @mliberty, thank you for the reply. Your answer is helpful but while debugging, I realised my real question is how to keep dut_power ON. I’m getting the error because I’m not using joulescope.close() or context manager because it’s powering down the dut. Please see the example code below
inititalize_dut() # slow process
time.sleep(1)
# Do test1
with js_dev:
do_measurement1()
# dut power down here, measurement1 and measurement2 is run by pytest
# Do test2
with js_dev:
do_measurement2()
Hi @jj110 - Your Joulescopes keep the path from Current+ to Current- enabled by default when you close the Joulescope. Here is code to demonstrate:
import joulescope
import time
device = joulescope.scan_require_one()
for i in range(10):
print('open')
with device:
time.sleep(1)
print('close')
time.sleep(1)
I used an LED and power supply set to 10 mA limit to check that the LED remained illuminated through these cycles using both a JS110 and JS220.
Thanks @mliberty for the script. You are right it’s a different issue. The symptom mislead my debugging. For now, I will just mask the error until I find the real culprit. Thanks for the help.