Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@setupSetParam("Hardware Model")
def setHwModel(self, model, kwargs=None):
self.model = model
self.model_kwargs = kwargs
self._updateHwModel()
self.sigParametersChanged.emit()
@setupSetParam("Total Samples")
def setMaxSamples(self, samples):
self.maxsamples = samples
self.oa.setMaxSamples(samples)
@setupSetParam("Device Serial Number")
def setSelectedDevice(self, snum):
self.serialNumber = snum
@setupSetParam("Stream Mode")
def setStreamMode(self, enabled):
self._stream_mode = enabled
if enabled:
self.findParam('Pre-Trigger Samples').setValue(0, ignoreReadonly=True)
self.findParam('Pre-Trigger Samples').setReadonly(True)
self.findParam('Total Samples').setLimits((0, 100E6))
else:
self.findParam('Pre-Trigger Samples').setReadonly(False)
self.findParam('Total Samples').setLimits((0, self.oa.hwMaxSamples))
#Write to FPGA
base = self.oa.sendMessage(CODE_READ, ADDR_SETTINGS)[0]
if enabled:
val = base | (1<<4)
else:
@setupSetParam("Traces per Attack")
def set_traces_per_attack(self, trace):
if trace < 0:
#Get maximum traces from source
ts = self.getTraceSource()
if ts is None:
raise ValueError("traceSource not yet set in attack - set TraceSource first to use automatic getTracesPerAttack")
trace = self.getTraceSource().num_traces()
self._tracePerAttack = trace
@setupSetParam("Mode")
def setMode(self, mode):
""" Input to trigger module options: 'rising edge', 'falling edge', 'high', 'low' """
if mode == 'rising edge':
trigmode = SETTINGS_TRIG_HIGH | SETTINGS_WAIT_YES
elif mode == 'falling edge':
trigmode = SETTINGS_TRIG_LOW | SETTINGS_WAIT_YES
elif mode == 'high':
trigmode = SETTINGS_TRIG_HIGH | SETTINGS_WAIT_NO
elif mode == 'low':
trigmode = SETTINGS_TRIG_LOW | SETTINGS_WAIT_NO
else:
raise ValueError, "%s invalid trigger mode"%mode
@setupSetParam('Input')
def setTraceSource(self, traceSource):
#Avoid doing processing when set to same value
if self._traceSource == traceSource:
return
if self._traceSource:
self._traceSource.sigTracesChanged.disconnect(self.processTraces)
if traceSource:
traceSource.sigTracesChanged.connect(self.processTraces)
self._traceSource = traceSource
self.processTraces()
@setupSetParam("Decimation = N:1")
def _setDecFactor(self, dec=1):
self._dec_factor = dec
@setupSetParam("Trace Format")
def set_trace_format(self, trace_format):
self._trace_format = trace_format
@setupSetParam("SmartCard Protocol")
def setProtocol(self, con):
self.protocol = con
if self.protocol is not None:
self.params.append(self.protocol.getParams())
self.protocol.setReaderHardware(self.driver)