diff options
author | Daniel Friesel <daniel.friesel@uos.de> | 2019-10-29 15:50:29 +0100 |
---|---|---|
committer | Daniel Friesel <daniel.friesel@uos.de> | 2019-10-29 15:50:29 +0100 |
commit | bac876794c0b162014beb841f21c5b62f9298091 (patch) | |
tree | 18cf314a1ca9c361ac1444ba56eb8bb721580675 | |
parent | dc219e925f42222f0079a19379abcc7404f98de6 (diff) |
support arbitrarily long measurements
-rwxr-xr-x | bin/msp430-etv | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/bin/msp430-etv b/bin/msp430-etv index 3957a33..206a7c2 100755 --- a/bin/msp430-etv +++ b/bin/msp430-etv @@ -11,10 +11,11 @@ from shutil import which import subprocess import sys import tempfile +import time opt = dict() -def measure_data(filename, time): +def measure_data(filename, duration): # libmsp430.so must be available if not 'LD_LIBRARY_PATH' in os.environ: os.environ['LD_LIBRARY_PATH'] = '{}/var/projects/msp430/MSP430Flasher_1.3.15'.format(os.environ['HOME']) @@ -29,7 +30,19 @@ def measure_data(filename, time): else: output_handle = tempfile.TemporaryFile('w+') - res = subprocess.run([energytrace_cmd, str(duration)], stdout = output_handle, universal_newlines = True) + energytrace = subprocess.Popen([energytrace_cmd, str(duration)], stdout = output_handle, universal_newlines = True) + + try: + if duration: + time.sleep(duration) + else: + print('Press Ctrl+C to stop measurement') + while True: + time.sleep(3600) + except KeyboardInterrupt: + energytrace.send_signal(subprocess.signal.SIGTERM) + + energytrace.communicate(timeout=5) output_handle.seek(0) output = output_handle.read() |