summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2021-11-07 20:11:19 +0100
committerDaniel Friesel <derf@finalrewind.org>2021-11-07 20:11:19 +0100
commit3b9c08c0b767d8510c8dc36a094ef3a9d1b3c911 (patch)
tree316ddde47f86565942402f493ec9e4994e9230d4 /bin
parentdc1bad2e71d164e4ac0173b4ec6cb2210ffdc590 (diff)
Report sample rate after measurement
Diffstat (limited to 'bin')
-rwxr-xr-xbin/korad-logger10
1 files changed, 8 insertions, 2 deletions
diff --git a/bin/korad-logger b/bin/korad-logger
index d73cff0..2b540a0 100755
--- a/bin/korad-logger
+++ b/bin/korad-logger
@@ -270,8 +270,6 @@ def measure_data(
signal.signal(signal.SIGQUIT, graceful_exit)
korad = KA320(port, channel)
- start_ts = time.time()
-
if filename is not None:
output_handle = open(filename, "w+")
else:
@@ -307,6 +305,8 @@ def measure_data(
else:
print(f"Starting data acquisition. Press Ctrl+C to stop.")
+ start_ts = time.time()
+
print("# Device: " + korad.get_id(), file=output_handle)
print("# Timestamp Voltage Current", file=output_handle)
while not terminate_measurement:
@@ -352,6 +352,12 @@ def measure_data(
output = output_handle.read()
output_handle.close()
+ # exclude header
+ output_len = len(output.splitlines()) - 2
+ print(
+ f"Logged {output_len:d} samples in {ts - start_ts:.0f} seconds (mean sample rate: {output_len / (ts - start_ts) :.1f} Hz)"
+ )
+
return output