From 3b9c08c0b767d8510c8dc36a094ef3a9d1b3c911 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Sun, 7 Nov 2021 20:11:19 +0100 Subject: Report sample rate after measurement --- bin/korad-logger | 10 ++++++++-- 1 file 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 -- cgit v1.2.3