218
edits
Changes
no edit summary
A basic script would look like this:
from chipwhisperer.common.scripts.base import UserScriptBase
#The environment is already set, lets do our first capture
self.api.capture1()
</pre>
User scripts should inherit from UserScriptBase that specifies the run() method that is called when clicking it in the menu or pressing the attack button (in the analyzer tool).
The section "if __name__ == '__main__':" is not mandatory, but is recommended if you want to run the script from the terminal. In this case, you don't need to use the GUI, the capture can be performed using only the API. Ex.:
<pre>
if __name__ == '__main__':
import sys
api = CWCoreAPI() # Instantiate the API
api.runScriptClass(UserScript) # Run UserScript through the API
</pre>
or if you want the GUI:
<pre>
if __name__ == '__main__':
import sys
Parameter.usePyQtGraph = True
api = CWCoreAPI() # Instantiate the API
gui = cwc.CWAnalyzerGUI(api) # Instantiate the GUI
gui.show()
api.runScriptClass(UserScript) # Run UserScript through the API
sys.exit(app.exec_())
</pre>
New scripts can be added to the tool's menu automatically by saving it in its respective script folder: