DeviceSetupFailure Automation Analog Capture

The code below regularly crashes, if I let it run for a couple of minutes. It never reached 10min so far. I’d like to run it for a couple of hours. Why could it be that the Device Setup fails? Any suggestion would be appreciated.

Code:
#########################################################
with automation.Manager.connect(port=10430) as manager:
dev_conf = automation.LogicDeviceConfiguration(
enabled_analog_channels=[0],
analog_sample_rate=625000,
)
cap_conf = automation.CaptureConfiguration(
capture_mode=automation.TimedCaptureMode(duration_seconds=T_sample)
)
abs_path = ‘C:\work\git\vinsontruck-python-tools\scripts\out\’
with manager.start_capture(device_configuration=dev_conf,
capture_configuration=cap_conf) as capture:
capture.wait()
capture.export_raw_data_csv(abs_path, analog_channels=[0])
ntc_dat = pd.read_csv(abs_path + ‘analog.csv’)
ntc_u_arr = ntc_dat[“Channel 0”].to_numpy()
u_mean = np.mean(ntc_u_arr)
u_std = np.std(ntc_u_arr)
return (u_mean, u_std)
#########################################################
Error (last view lines of terminal ouput, the two numbers are just u_mean and time):
INFO:saleae.automation.manager:sub ChannelConnectivity.IDLE
INFO:saleae.automation.manager:sub ChannelConnectivity.CONNECTING
INFO:saleae.automation.manager:sub ChannelConnectivity.READY
2.72
487.97
INFO:saleae.automation.manager:sub ChannelConnectivity.IDLE
INFO:saleae.automation.manager:sub ChannelConnectivity.CONNECTING
INFO:saleae.automation.manager:sub ChannelConnectivity.READY
2.72
496.55
INFO:saleae.automation.manager:sub ChannelConnectivity.CONNECTING
INFO:saleae.automation.manager:sub ChannelConnectivity.READY
Traceback (most recent call last):
File “c:/…/scripts/MWE.py”, line 44, in
(u_ntc, std_ntc) = getNTCu(T_sample_ntc)
File “c:/…/scripts/MWE.py”, line 17, in getNTCu
with manager.start_capture(device_configuration=dev_conf, capture_configuration=cap_conf) as capture:
File “C:.…\lib\site-packages\saleae\automation\manager.py”, line 583, in start_capture
reply: saleae_pb2.StartCaptureReply = self.stub.StartCapture(
File “C:\Program Files\WinPython38_64bit\python-3.8.6.amd64\lib\contextlib.py”, line 131, in exit
self.gen.throw(type, value, traceback)
File “C:.…\lib\site-packages\saleae\automation\errors.py”, line 121, in _error_handler
raise grpc_error_to_exception(exc) from None
saleae.automation.errors.DeviceError: Error interacting with device during capture: DeviceSetupFailure.

I am using windows 11, Python 3.8.6 in VS Code 194.0, Logic 2.4.14, Logic 8 hardware, USB cable directly connected to mainboard of laptop, I tried both laptop USB ports
Thank you for your help

My guess would be you might be having some USB intermittent issues. Does it happen if PC stays ‘busy’ (i.e., actively using PC keyboard/mouse while script is running vs. console is essentially ‘idle’ other than the script?) Does the Logic 2.exe process hang/crash in Task Manager?

Quick tips:

  • Make sure the Logic is only device on USB, if possible
    (no other USB devices connected/in use)
  • Make sure PC is on AC vs. battery power
    (set on full/high performance, not battery/lower power optimized)
  • Make sure USB port won’t go to sleep
    (Turn off all USB power saving options, so ‘always on’ and Windows won’t disable/power off port)
  • Try the same script on a different PC (if possible, a different model) and see if you get the same result

More possible links w/ ideas to try: