@mliberty Trying to work around email block issues.
I followed the instructions and uninstall psutil and deleted the .pyd file and reinstalled. That seemed to work.
When I run the script to capture a 5 second datalog the script runs indefinitely and I have to press crtl-c to terminate it:
When I do terminate the data capture a file is created. The file size is proportional to the amount of time I let the capture run:
But regardless of how short a time I allow it to run, when I open the file in the GUI, it shows a several hundred second long data capture:
The timebase seems off. I’ve attached the code producing the data capture. Its your sample code with a slight modification.
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright 2020 Jetperch LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Capture samples to JLS files for all connected Joulescopes."""
from joulescope import scan
from joulescope.data_recorder import DataRecorder
import argparse
import os
import sys
import signal
import time
import datetime
import subprocess
def get_parser():
p = argparse.ArgumentParser(
description='Read data from Joulescope.')
p.add_argument('--duration', '-d',
type=lambda d: d if d is None else float(d),
help='The capture duration in seconds.')
p.add_argument('--frequency', '-f',
help='The sampling frequency in Hz.')
p.add_argument('--product_tag', '-p',
default='NOTAG',
help='Product tags are written to the output file for easier access. If product_tag is R900V5, the output file will be YYYYMMDDSS_R900v5.jls')
p.add_argument('--command', '-c',
type=str,
default='',
help='Used to embed a command that you want to execute while the datalogger is running.')
p.add_argument('--timedelay', '-t',
type=float,
default=0.0,
help='Used to wait X.X seconds before command is executed.')
return p
def run():
return_code = 0
quit_ = False
def do_quit(*args, **kwargs):
nonlocal quit_
quit_ = 'quit from SIGINT'
def on_stop(event, message):
nonlocal quit_
quit_ = 'quit from stop'
args = get_parser().parse_args()
signal.signal(signal.SIGINT, do_quit)
devices = scan(config='auto')
print(f'Current Joulescopes: {devices}')
items = []
if devices:
try:
for device in devices:
if args.frequency:
try:
device.parameter_set('sampling_frequency', int(args.frequency))
except Exception:
# bad frequency selected, display warning & exit gracefully
freqs = [f[2][0] for f in device.parameters('sampling_frequency').options]
print(f'Unsupported frequency selected: {args.frequency}')
print(f'Supported frequencies = {freqs}')
quit_ = True
return_code = -1
break
# Create a unique report name based off date and time
datalogger_name = datetime.datetime.now().strftime(f"%Y%m%d_%H%M%S_{args.product_tag}.jls")
filepath = r'C:\CBAT_Test\Datalogs' + '\\' + datalogger_name
print()
print(filepath)
print()
device.open()
recorder = DataRecorder(filepath,
calibration=device.calibration)
items.append([device, recorder])
device.stream_process_register(recorder)
if not quit_:
for device, _ in items:
device.start(stop_fn=on_stop, duration=args.duration)
if args.command:
time.sleep(args.timedelay)
subprocess.run(args.command)
print('Capturing data: type CTRL-C to stop')
while not quit_:
time.sleep(0.01)
finally:
for device, recorder in items:
try:
device.stop()
recorder.close()
device.close()
except Exception:
print('exception during close')
return_code = -2
return return_code
else:
print('No Joulescope Detected. Did you forgot to plug it in?')
sys.exit(f"##teamcity[buildStatus status='FAILURE' text='No Joulescope Detected. Did you forgot to plug it in?']")
if __name__ == '__main__':
run()