Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __init__(self):
super(AuxList, self).__init__()
self._next_id = 1
# List aux modules and parameter groups for each timing
self._aux_items = OrderedDict()
self._param_groups = {}
for t in list(self._valid_timings.keys()):
self._aux_items[t] = []
self._param_groups[t] = Parameter(name=self._valid_timings[t], type='group')
self.getParams().append(self._param_groups[t])
self.getParams().addChildren([
{'name':'Help', 'type':'action', 'action':self._showHelp}
])
self.getParams().refreshAllParameters()
def setupTraceParam(self):
self.traceParams = Parameter(self, name='Trace Setup', type='group', children=[
{'name':'Starting Trace', 'key':'strace', 'type':'int', 'value':0, 'action':self.updateGenericScript},
{'name':'Traces per Attack', 'key':'atraces', 'type':'int', 'limits':(1, 1E6), 'value':1, 'action':self.updateGenericScript},
{'name':'Attack Runs', 'key':'runs', 'type':'int', 'limits':(1, 1E6), 'value':1, 'action':self.updateGenericScript},
{'name':'Reporting Interval', 'key':'reportinterval', 'type':'int', 'value':10, 'action':self.updateGenericScript},
])
self.addFunction("init", "setTraceStart", "0")
self.addFunction("init", "setTracesPerAttack", "1")
self.addFunction("init", "setIterations", "1")
self.addFunction("init", "setReportingInterval", "10")
# Download all hardware setup parameters
for cmd in lstexample: self.api.setParameter(cmd)
# Let's only do a few traces
self.api.setParameter(['Generic Settings', 'Acquisition Settings', 'Number of Traces', 5000])
# Throw away first few
self.api.capture1()
self.api.capture1()
if __name__ == '__main__':
import chipwhisperer.capture.ui.CWCaptureGUI as cwc # Import the ChipWhispererCapture GUI
from chipwhisperer.common.utils.parameter import Parameter # Comment this line if you don't want to use the GUI
Parameter.usePyQtGraph = True # Comment this line if you don't want to use the GUI
api = CWCoreAPI() # Instantiate the API
app = cwc.makeApplication("Capture") # Change the name if you want a different settings scope
gui = cwc.CWCaptureGUI(api) # Comment this line if you don't want to use the GUI
gui.show() # Comment this line if you don't want to use the GUI
api.runScriptClass(UserScript) # Run the User Script (executes "run()" by default)
app.exec_() # Comment this line if you don't want to use the GUI
def __init__(self, api):
self._api = api
self.valid_preprocessingModules = pluginmanager.getPluginsInDictFromPackage("chipwhisperer.analyzer.preprocessing", False, False)
self.params = Parameter(name="Preprocessing Settings", type='group')
self._moduleParams = [
Parameter(name='self.ppmod[%d]' % (i), type='group') for i in range(self._num_modules)
]
self._initModules()
self.params.addChildren([
{'name':'Selected Modules', 'type':'group', 'children':[
{'name':'self.ppmod[%d]' % (step), 'type':'list', 'values':self.valid_preprocessingModules,
'get':partial(self.getModule, step), 'set':partial(self.setModule, step)} for step in range(0, len(self._modules))
]},
])
for m in self._moduleParams:
self.params.append(m)
# Let's only do a few traces
self.api.setParameter(['Generic Settings', 'Acquisition Settings', 'Number of Traces', 50])
# Throw away first few
self.api.capture1()
self.api.capture1()
# Capture a set of traces and save the project
# self.api.captureM()
# self.api.saveProject("../../../projects/test.cwp")
if __name__ == '__main__':
import chipwhisperer.capture.ui.CWCaptureGUI as cwc # Import the ChipWhispererCapture GUI
from chipwhisperer.common.utils.parameter import Parameter # Comment this line if you don't want to use the GUI
Parameter.usePyQtGraph = True # Comment this line if you don't want to use the GUI
api = CWCoreAPI() # Instantiate the API
app = cwc.makeApplication("Capture") # Change the name if you want a different settings scope
gui = cwc.CWCaptureGUI(api) # Comment this line if you don't want to use the GUI
gui.show() # Comment this line if you don't want to use the GUI
api.runScriptClass(UserScript) # Run the User Script (executes "run()" by default)
app.exec_() # Comment this line if you don't want to use the GUI
def __init__(self, api):
self._api = api
self.valid_preprocessingModules = pluginmanager.getPluginsInDictFromPackage("chipwhisperer.analyzer.preprocessing", False, False)
self.params = Parameter(name="Preprocessing Settings", type='group')
self._moduleParams = [
Parameter(name='self.ppmod[%d]' % (i), type='group') for i in range(self._num_modules)
]
self._initModules()
self.params.addChildren([
{'name':'Selected Modules', 'type':'group', 'children':[
{'name':'self.ppmod[%d]' % (step), 'type':'list', 'values':self.valid_preprocessingModules,
'get':partial(self.getModule, step), 'set':partial(self.setModule, step)} for step in range(0, len(self._modules))
]},
])
for m in self._moduleParams:
self.params.append(m)
def saveAllSettings(self, fname=None, onlyVisibles=False):
""" Save registered parameters to a file, so it can be loaded again latter. Don't use."""
if fname is None:
fname = os.path.join(self.datadirectory, 'settings.cwset')
logging.info('Saving settings to file: ' + fname)
Parameter.saveRegistered(fname, onlyVisibles)
def __init__(self, standalone=False):
self.standalone = standalone
self.serialnum = None
self.params = Parameter(name=self.getName(), type='group')
if standalone:
self.setSerial = self._setSerial
def __init__(self, oadcInstance):
self.portName = ''
self.ser = None
self.params = Parameter(name=self.getName(), type='group')
self.params.addChildren([
{'name':'Refresh List', 'type':'action', 'action':self.serialRefresh},
{'name':'Selected Port', 'type':'list', 'values':[''], 'get':self.getPortName, 'set':self.setPortName},
])
self.scope = oadcInstance
def dcmTimeout(self):
if self.connectStatus.value():
try:
self.qtadc.sc.getStatus()
# The following happen with signals, so a failure will likely occur outside of the try...except
# For this reason we do the call to .getStatus() to verify USB connection first
Parameter.setParameter(['OpenADC', 'Clock Setup', 'Refresh Status', None], blockSignal=True)
Parameter.setParameter(['OpenADC', 'Trigger Setup', 'Refresh Status', None], blockSignal=True)
except USBError:
self.dis()
raise Warning("Error in the scope. It may have been disconnected.")
except Exception as e:
self.dis()
raise e