本文整理匯總了Python中chipwhisperer.common.utils.parameter.Parameter.append方法的典型用法代碼示例。如果您正苦於以下問題:Python Parameter.append方法的具體用法?Python Parameter.append怎麽用?Python Parameter.append使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類chipwhisperer.common.utils.parameter.Parameter
的用法示例。
在下文中一共展示了Parameter.append方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: ChipWhispererExtra
# 需要導入模塊: from chipwhisperer.common.utils.parameter import Parameter [as 別名]
# 或者: from chipwhisperer.common.utils.parameter.Parameter import append [as 別名]
class ChipWhispererExtra(Parameterized):
_name = 'CW Extra'
def __init__(self, parentParam, cwtype, scope, oa):
#self.cwADV = CWAdvTrigger()
if cwtype == "cwrev2":
self.cwEXTRA = CWExtraSettings(self, oa)
elif cwtype == "cwlite":
self.cwEXTRA = CWExtraSettings(self, oa, hasFPAFPB=False, hasGlitchOut=True, hasPLL=False)
else:
raise ValueError("Unknown ChipWhisperer: %s" % cwtype)
self.enableGlitch = True
if self.enableGlitch:
self.glitch = ChipWhispererGlitch.ChipWhispererGlitch(self, cwtype, scope, oa)
self.params = Parameter(name=self.getName(), type='group')
self.params.append(self.cwEXTRA.getParams())
self.params.append(self.glitch.getParams())
def armPreScope(self):
if self.enableGlitch:
self.glitch.armPreScope()
def armPostScope(self):
if self.enableGlitch:
self.glitch.armPostScope()
示例2: setPreprocessing
# 需要導入模塊: from chipwhisperer.common.utils.parameter import Parameter [as 別名]
# 或者: from chipwhisperer.common.utils.parameter.Parameter import append [as 別名]
def setPreprocessing(self, num, module):
"""Insert the preprocessing module selected from the GUI into the list of active modules.
This ensures that the options for that module are then displayed in the GUI, along with
writing the auto-generated script.
"""
#Walk backwards to find previous trace source
last_trace_src = self.cwGUI.api.project().traceManager()
for i in range(num, 0, -1):
if self.preprocessingListGUI[i] is not None:
last_trace_src = self.preprocessingListGUI[i]
break
if self.preprocessingListGUI[num] is not None:
self.preprocessingListGUI[num].deregister()
self.preprocessingParams.getChild('Pre-Processing Mod. #%d'% num).delete()
if module:
self.preprocessingListGUI[num] = module(traceSource=last_trace_src)
self.preprocessingListGUI[num].scriptsUpdated.connect(self.reloadScripts)
par = Parameter(name = 'Pre-Processing Mod. #%d'% num, type = "group")
par.append(self.preprocessingListGUI[num].getParams())
self.preprocessingParams.append(par)
else:
self.preprocessingListGUI[num] = None
self.reloadScripts()
示例3: AttackScriptGen
# 需要導入模塊: from chipwhisperer.common.utils.parameter import Parameter [as 別名]
# 或者: from chipwhisperer.common.utils.parameter.Parameter import append [as 別名]
class AttackScriptGen(Parameterized):
_name = "Attack Script Generator"
def __init__(self, cwGUI):
self.cwGUI = cwGUI
self.locked = False
self.utilList = []
self.scriptList = []
self.scriptList.append({'widget':MainScriptEditor(self.cwGUI)})
self.scriptList[0]['filename'] = self.scriptList[0]['widget'].filename
self.scriptList[0]['dockname'] = 'Auto-Generated'
self.defaultEditor = self.scriptList[0]
autogen = (self.defaultEditor['dockname'], self.defaultEditor['filename'])
self.preprocessingListGUI = [None, None, None, None]
self.setAttack(self.cwGUI.api.valid_attacks.get("CPA", None), blockSignal=True)
self.getParams().addChildren([
{'name':'Attack Script', 'type':'group', 'children':[
{'name':'Filename', 'key':'attackfilelist', 'type':'filelist', 'values':{autogen:0}, 'value':0, 'editor':self.editorControl,},
]},
{'name':'Pre-Processing', 'type':'group', 'children':[
{'name':'Module #%d' % step, 'type':'list', 'values':self.cwGUI.api.valid_preprocessingModules, 'get':partial(self.getPreprocessing, step), 'set':partial(self.setPreprocessing, step)} for step in range(0, len(self.preprocessingListGUI))
]},
{'name':'Attack', 'type':'group', 'children':[
{'name':'Module', 'type':'list', 'values':self.cwGUI.api.valid_attacks, 'get':self.getAttack, 'set':self.setAttack},
]},
])
self.params.init()
self.preprocessingParams = Parameter(name="Preprocessing", type='group')
self.attackParams = Parameter(name="Attack", type='group')
self.params.getChild(['Attack','Module']).stealDynamicParameters(self.attackParams)
self.cwGUI.api.sigTracesChanged.connect(self.updateAttackTraceLimits)
def flushTimer(self):
"""Flush all pending script updates"""
[p.updateDelayTimer.flush() for p in self.preprocessingListGUI if p is not None]
self.attack.updateDelayTimer.flush()
def updateAttackTraceLimits(self):
self.attack.setTraceLimits(self.cwGUI.api.project().traceManager().numTraces(), self.cwGUI.api.project().traceManager().numPoints())
def editorControl(self, filename, filedesc, default=False, bringToFront=True):
"""This is the call-back from the script editor file list, which opens editors"""
# Find filename
thisEditor = None
for e in self.scriptList:
if e['filename'] == filename:
thisEditor = e
break
if thisEditor is None:
thisEditor = {'widget':MainScriptEditor(parent=self.cwGUI, filename=filename)}
thisEditor['filename'] = filename
thisEditor['dockname'] = filedesc
self.scriptList.append(thisEditor)
# Update all docks if required
thisEditor['dockname'] = filedesc
self.editorDocks()
if bringToFront:
thisEditor['dock'].show()
thisEditor['dock'].raise_()
if default:
# Set as default for attacks etc
self.defaultEditor = thisEditor
def editorDocks(self):
"""Ensure we have a script editor window for each referenced analyzer script file"""
for script in self.scriptList:
dockname = "Analysis Script: %s" % script['dockname']
# No previous dock, do setup
if 'dock' not in script.keys():
self.__runScriptConverter = partial(self.runScriptFunction, filename=script['filename'])
script['widget'].editWindow.runFunction.connect(self.__runScriptConverter)
script['dock'] = self.cwGUI.addDock(script['widget'], name=dockname, area=Qt.BottomDockWidgetArea)
script['dock'].setWindowTitle(dockname)
def getPreprocessing(self, num):
return self.preprocessingListGUI[num]
@setupSetParam("")
def setPreprocessing(self, num, module):
"""Insert the preprocessing module selected from the GUI into the list of active modules.
This ensures that the options for that module are then displayed in the GUI, along with
writing the auto-generated script.
"""
#Walk backwards to find previous trace source
last_trace_src = self.cwGUI.api.project().traceManager()
for i in range(num, 0, -1):
#.........這裏部分代碼省略.........
示例4: ChipWhispererComm
# 需要導入模塊: from chipwhisperer.common.utils.parameter import Parameter [as 別名]
# 或者: from chipwhisperer.common.utils.parameter.Parameter import append [as 別名]
class ChipWhispererComm(Parameterized):
_name = "Sakurag"
CODE_READ = 0x80
CODE_WRITE = 0xC0
ADDR_STATUS = 49
ADDR_FIFO = 50
FLAG_RESET = 0x01
FLAG_WRFULL = 0x02
FLAG_RDEMPTY = 0x04
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 _setSerial(self, serialnum):
self.serialnum = serialnum
def reset(self):
self.oa.sendMessage(self.CODE_WRITE, self.ADDR_STATUS, [self.FLAG_RESET], Validate=False)
time.sleep(0.05)
self.oa.sendMessage(self.CODE_WRITE, self.ADDR_STATUS, [0x00], Validate=False)
def con(self, scope = None):
if scope and scope.qtadc and scope.qtadc.sc:
self.oa = scope.qtadc.sc
else:
if self.serialnum is not None:
self.qtadc = openadc_qt.OpenADCQt()
self.params.append(self.qtadc.getParams())
self.oaiface = ftdi.OpenADCInterface_FTDI(None, self.qtadc)
self.params.append(self.oaiface.getParams())
self.oaiface.setSerialNumberLimits([self.serialnum])
self.oaiface.setSelectedDevice(self.serialnum)
self.oaiface.con()
self.oa = self.qtadc.sc
else:
raise Warning("No OpenADC detected - did you connect in scope module already and/or set serial number (hit 'REFRESH')?")
# Reset AES Core
self.oa.sendMessage(self.CODE_WRITE, self.ADDR_STATUS, [self.FLAG_RESET], Validate=False)
self.oa.sendMessage(self.CODE_WRITE, self.ADDR_STATUS, [0x00], Validate=False)
return True
def disconnect(self):
return
def flush(self):
while (self.readStatus() & self.FLAG_RDEMPTY) != self.FLAG_RDEMPTY:
self.oa.sendMessage(self.CODE_READ, self.ADDR_FIFO, Validate=False)
def readStatus(self):
b = self.oa.sendMessage(self.CODE_READ, self.ADDR_STATUS, Validate=False)
return b[0]
def writeMsg(self, msg):
for b in msg:
# while (self.readStatus() & self.FLAG_WRFULL) == self.FLAG_WRFULL:
# pass
self.oa.sendMessage(self.CODE_WRITE, self.ADDR_FIFO, [b], Validate=False)
def readMsg(self, nbytes):
msg = bytearray()
for i in range(0, nbytes):
if self.readStatus() & self.FLAG_RDEMPTY:
pass
b = self.oa.sendMessage(self.CODE_READ, self.ADDR_FIFO, Validate=False)
msg.append(b[0])
return msg
def write(self, address, MSB, LSB):
msg = bytearray(5)
msg[0] = 0x01
msg[1] = (address >> 8) & 0xFF # MSB
msg[2] = address & 0xFF # LSB
msg[3] = MSB
msg[4] = LSB
# msg = bytearray(strmsg)
# print "Write: %x %x %x %x %x"%(msg[0],msg[1],msg[2],msg[3],msg[4])
self.writeMsg(msg)
def read(self, address):
self.flush()
msg = bytearray(3)
msg[0] = 0x00
msg[1] = (address >> 8) & 0xFF # MSB
#.........這裏部分代碼省略.........
示例5: TraceExplorerDialog
# 需要導入模塊: from chipwhisperer.common.utils.parameter import Parameter [as 別名]
# 或者: from chipwhisperer.common.utils.parameter.Parameter import append [as 別名]
class TraceExplorerDialog(AutoScript, Parameterized):
"""Open dialog to explore trace properties, data graphs, etc"""
_name = "Trace Explorer"
def __init__(self, parent):
AutoScript.__init__(self)
self.enabled = False
self.autoScriptInit()
# Add example scripts to this list
self.exampleScripts = [PartitionDisplay(self), TextDisplay(self)]
# Add Scripts
self.setupCommonScripts()
self.progressBar = ProgressBar(show=False)
def setupCommonScripts(self):
# Setup parameer tree
self.getParams().addChildren([
{'name':'Enabled', 'key':'enabled', 'type':'bool', 'default':self.getEnabled(), 'get':self.getEnabled, 'set':self.setEnabled}
])
self.commonScriptParams = []
self.paramCommonScripts = Parameter(name='Common Scripts', type='group', children=self.commonScriptParams)
for example in self.exampleScripts:
self.paramCommonScripts.append(example.getParams())
example.scriptsUpdated.connect(self.updateScripts)
example.runScriptFunction.connect(self.runScriptFunction.emit)
self.getParams().append(self.paramCommonScripts)
self.paramCommonScripts.hide()
self.updateScripts()
def getEnabled(self):
return self.enabled
@setupSetParam("Enabled")
def setEnabled(self, enabled):
self.enabled = enabled
self.paramCommonScripts.show(enabled)
self.updateChildren()
####COMMON SCRIPTING STUFF
def getProgressIndicator(self):
return self.progressBar
def updateChildren(self):
for example in self.exampleScripts:
if hasattr(example, 'updateScript'):
example.updateScript("traceexplorer_show")
self.updateScripts()
def updateScripts(self):
for index, example in enumerate(self.exampleScripts):
if hasattr(example, "_smartstatements"):
for k in example._smartstatements:
statements = example.getStatements(k)
if len(statements) > 0:
prefix = example.__class__.__name__ + "_"
self._smartstatements[prefix + k] = example._smartstatements[k]
self._smartstatements[prefix + k].addSelfReplacement("exampleScripts[%d]." % index)
for k in example.getImportStatements():
self.importsAppend(k)
self.scriptsUpdated.emit()