7.15 Example usecase script definition

This is an example of a complete usecase script.

After a usecase script has been defined, you can use the command-line options in DS-5 to query and execute the script when connected to a target.

Example 7-13 Examples

"""
USECASE 

$Title$ Display Title

$Description$ A brief description of this usecase

# Refers to a function called myOptions which returns a list of options
$Options$ myOptions 

# Refers to a function called myValidation which validates the options in the script 
$Validation$ myValidation 

$Help$
usage: usecase.py [options]  
A longer description of this use case
And additional usage, descriptions of parameters and extra information.
...
...
$Help$

# Function called mainMethod which defines the entry point to this usecase
$Run$ mainMethod
"""
def myOptions():
      return [
          UseCaseScript.optionGroup(                 
              name="options",
              displayName="Usecase Options",                  
              childOptions=[                      
                  UseCaseScript.optionGroup(                         
                     name="connection",                         
                     displayName="Connection Options",
                     childOptions=[                             
                         UseCaseScript.integerOption(
                             name="cores",                                          
                             displayName="Number of cores",
                             defaultValue=1,
                             min=1,
                             max=16),                             
                         UseCaseScript.stringOption(
                             name="traceBuffer",
                             displayName="Trace Capture Method",
                             defaultValue="none"),                          
                     ]
                  ),                       
                  UseCaseScript.enumOption(                     
                  name="contextID",                     
                  displayName="Context ID Size",
                  values = [("8", "8 bits"), ("16", "16 bits"), ("32", "32 bits")],                      
                  defaultValue="32"),
              ]
          ),
      ]  
          
def myValidation(options):
    print "Performing validation..."   
    if(options.getOptionValue(“options.connection.cores”) > 8):
        UseCaseScript.error(“Having more than 8 cores is not allowed for this usecase”) 

def mainMethod(options, address):
    print "Running the main method"
    print "The address supplied %s" % address
Non-ConfidentialPDF file icon PDF versionARM DUI0446W
Copyright © 2010-2015 ARM. All rights reserved.