diff --git a/cw/simple_capture_aes_sca.py b/cw/simple_capture_aes_sca.py index 8bba18d45..769b8a969 100755 --- a/cw/simple_capture_aes_sca.py +++ b/cw/simple_capture_aes_sca.py @@ -17,8 +17,8 @@ from Crypto.Cipher import AES from tqdm import tqdm -from util import device, plot, trace_util from waverunner import WaveRunner +from util import device, plot, trace_util def abort_handler_during_loop(project, sig, frame): @@ -110,10 +110,6 @@ def abort_handler_during_loop(project, sig, frame): # Main loop for measurements with progress bar for _ in tqdm(range(cfg["capture"]["num_traces"]), desc='Capturing', ncols=80): - # Generate and load new text for this iteration - text = bytearray(cipher_gen.encrypt(text)) - cwfpgahusky.target.simpleserial_write('p', text) - # TODO: Useful code line for batch capture # cwfpgahusky..simpleserial_write("s", capture_cfg["batch_prng_seed"].to_bytes(4, "little")) @@ -121,6 +117,16 @@ def abort_handler_during_loop(project, sig, frame): # Arm Husky scope cwfpgahusky.scope.arm() + if USE_WAVERUNNER: + # Arm Waverunner scope + waverunner.arm() + + # Generate new text for this iteration + text = bytearray(cipher_gen.encrypt(text)) + # Load text and trigger execution + cwfpgahusky.target.simpleserial_write('p', text) + + if USE_HUSKY: # Capture Husky trace ret = cwfpgahusky.scope.capture(poll_done=False) i = 0 @@ -136,9 +142,6 @@ def abort_handler_during_loop(project, sig, frame): wave = cwfpgahusky.scope.get_last_trace(as_int=True) if USE_WAVERUNNER: - # Arm Waverunner scope - waverunner.arm() - # Capture and get Waverunner trace waves = waverunner.capture_and_transfer_waves() assert waves.shape[0] == cfg["waverunner"]["num_segments"] diff --git a/cw/waverunner.py b/cw/waverunner.py index f0d3d88b3..7987ae9c0 100755 --- a/cw/waverunner.py +++ b/cw/waverunner.py @@ -377,8 +377,7 @@ def capture_and_transfer_waves(self): """ # Don't process commands until the acqu is complete and wait until # processing is complete. - # Previously contained WAIT but did not work properly res = self._ask("WAIT 10;*OPC?") - res = self._ask("*OPC?") + res = self._ask("WAIT 10;*OPC?") assert res == "*OPC 1" # Transfer and parse waveform data. if self.acqu_channel == "C1":