diff options
author | Lennart <lekaiser@uos.de> | 2020-07-13 13:06:11 +0200 |
---|---|---|
committer | Lennart <lekaiser@uos.de> | 2020-07-13 13:06:11 +0200 |
commit | b5f7fd47d1ee66f20af50fae145990d4665b56c3 (patch) | |
tree | 540a8b84f28680dbce605702d2a0792d722c8514 | |
parent | 0bda106da0af4b9ba72f31930669fb5da1311d28 (diff) |
Added first version, kinda working but some tweaks needed. src directory of repository 'ba-lennart-kaiser' needs to in the python execution path
-rw-r--r-- | lib/harness.py | 33 | ||||
-rw-r--r-- | lib/runner.py | 31 |
2 files changed, 62 insertions, 2 deletions
diff --git a/lib/harness.py b/lib/harness.py index fe6cb9a..3b9db89 100644 --- a/lib/harness.py +++ b/lib/harness.py @@ -405,15 +405,46 @@ class OnboardTimerHarness(TransitionHarness): ret = '#include "driver/counter.h"\n' ret += "#define PTALOG_TIMING\n" ret += super().global_code() + if self.energytrace_sync == "led": + #TODO Make nicer + ret += """\nvoid runLASync(){ + // ======================= LED SYNC ================================ + ptalog.passTransition(0); + ptalog.startTransition(); + gpio.led_toggle(0); + gpio.led_toggle(1); + ptalog.stopTransition(counter); + + for (unsigned char i = 0; i < 4; i++) { + arch.sleep_ms(250); + } + + ptalog.passTransition(0); + ptalog.startTransition(); + gpio.led_toggle(0); + gpio.led_toggle(1); + ptalog.stopTransition(counter); + // ======================= LED SYNC ================================ + arch.sleep_ms(250); +}\n\n""" return ret def start_benchmark(self, benchmark_id=0): - ret = "counter.start();\n" + ret = "" + if self.energytrace_sync == "led": + ret += "runLASync();\n" + ret += "counter.start();\n" ret += "counter.stop();\n" ret += "ptalog.passNop(counter);\n" ret += super().start_benchmark(benchmark_id) return ret + def stop_benchmark(self): + ret = super().stop_benchmark() + if self.energytrace_sync == "led": + ret += "runLASync();\n" + return ret + def pass_transition( self, transition_id, transition_code, transition: object = None ): diff --git a/lib/runner.py b/lib/runner.py index def9c8f..3a201fc 100644 --- a/lib/runner.py +++ b/lib/runner.py @@ -9,7 +9,7 @@ Functions: get_monitor -- return Monitor class suitable for the selected multipass arch get_counter_limits -- return arch-specific multipass counter limits (max value, max overflow) """ - +import json import os import re import serial @@ -17,6 +17,7 @@ import serial.threaded import subprocess import sys import time +from data.timing.SigrokCLIInterface import SigrokCLIInterface class SerialReader(serial.threaded.Protocol): @@ -156,6 +157,7 @@ class EnergyTraceMonitor(SerialMonitor): self._start_energytrace() def _start_energytrace(self): + print("EnergyTrace Start") cmd = ["msp430-etv", "--save", self._output, "0"] self._logger = subprocess.Popen( cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True @@ -187,6 +189,33 @@ class EnergyTraceLogicAnalyzerMonitor(EnergyTraceMonitor): def __init__(self, port: str, baud: int, callback=None, voltage=3.3): super().__init__(port=port, baud=baud, callback=callback, voltage=voltage) + #TODO get length + options = {'length': 90, 'fake': False, 'sample_rate': 1_000_000} + self.log_file = 'logic_output_log_%s.json' % (time.strftime("%Y%m%d-%H%M%S")) + + # Initialization of Interfaces + self.sig = SigrokCLIInterface(sample_rate=options['sample_rate'], + sample_count=options['length'] * options['sample_rate'], fake=options['fake']) + + # Start Measurements + print("[ET LA] START MEASURE") + self.sig.runMeasureAsynchronous() + + def close(self): + super().close() + # Read measured data + print("[ET LA] Wait MEASURE") + self.sig.waitForAsynchronousMeasure() + print("[ET LA] WRITE MEASURE") + sync_data = self.sig.getData() + print("[ET LA] MEASURE LEN", len(sync_data.timestamps)) + with open(self.log_file, 'w') as fp: + json.dump(sync_data.getDict(), fp) + + def get_files(self) -> list: + print("[ET LA] FILE REQUEST") + return [self.log_file] + class MIMOSAMonitor(SerialMonitor): """MIMOSAMonitor captures serial output and MIMOSA energy data for a specific amount of time.""" |