Modify Sample Python Script

You can modify the sample Python scripts TestCollectContinuousHcs08.py and TestCollectAutomaticHcs08.py according to your needs to extend the functionality to other platforms. You can use these scripts as base for creating test scripts.

To create your scripts, you can modify the sample script as follows:

  1. Rename the script according to platform name.
  2. Rename the two classes inside the scripts.
  3. Update the references to these classes in the onBeforeLaunchStart(self) and runTraceDemo() functions. For example, in the onBeforeLaunchStart(self) function, replace TestConfigHcs08() with TestConfigABC() as follows, where ABC is the platform you are working on.
    if ( self.__enableTrace ):
    			self.__traceSession = TestConfigABC()
  4. Similarly, in the runTraceDemo() function, replace TestCollectContinuousHcs08() with TestCollectContinuousABC(), where ABC is the platform you are working on.
  5. Modify the configuration details in the Config data for the script section (lines 20 to 23) as follows:
    1. Update platform name in test_platform. The platform type string is case-sensitive and can take any one of the following values: "HCS08", "Kinetis", "CFv1", "CFv2", "CFv3", "CFv4", "56xx", "DSC", "S12Z".
    2. Update project name in test_project.
    3. Update launch configuration name in test_launchconfig.
    4. Update the breakpoint line in test_bp_line, that is the line where you want to set a breakpoint. For example, for the Kinetis stationery project, you may use line 21 for the breakpoint.
  6. Update other configuration details after line 57 according to your needs.
    Note: Besides checking that trace is collected and a new result set named 0-{launch_config_name} is created in the Software Analysis view, you may edit the file 0-{launch_config_name}.traceConfig available in the project root. You can see that the attributes corresponding to the self.__analysisConfig.setXXX functions called in the sample scripts are changed in the .traceConfig file. For example, if self.__analysisConfig.setContinuousTrace(True) is called from the scripts (see line 59 in the sample scripts) then in the .traceConfig file, you should notice that the "Continuous" attribute is changed to true. The remote launch creates a copy of the launch configuration created by the New Project Wizard and deletes it after the debug session terminates successfully, so checking the trace and profile tab controls for changes is not possible.

This is how you can modify a sample Python script.