This function registers a hook or callback function.
[Specification format]
[Argument(s)]
|
|
scriptFile
|
Specify the script file where the hook or callback function is defined.
|
[Return value]
None
[Detailed description]
- | This function loads scriptFile, and registers a hook or callback function in the script file.
There is no problem even if functions other than a hook or callback function are declared.
The hook or the callback function is registered when the script file is ended. |
- | If Hook functions are declared, they are called after CS+ events occur. |
Caution | Event processing by CS+ is not completed unless execution of the hook function completes or control returns to the calling program. |
- | The types of hook function are shown below.
Note that hook functions do not take parameters. |
|
|
BeforeBuild
|
Before build
|
BeforeDownload
|
Before download
|
AfterDownload
|
After download
|
AfterCpuReset
|
After CPU reset
|
BeforeCpuRun
|
Before execute
|
AfterCpuStop
|
After break
|
AfterActionEvent
|
After action event (only Printf event)
|
AfterInterrupt
|
After acceptance of specified exception cause code
(the target is the exception cause code set in debugger.Interrupt.Notification)
|
AfterTimer
|
After occurrence of timer interrupt
(the target is the timer interrupt set in debugger.Interrupt.SetTimer)
|
Example | Sample script file |
def BeforeDownload():
# Processing you want to perform before the download
|
- | If callback functions are declared, they are called after CS+ events occur. |
- | The callback function name is fixed to "pythonConsoleCallback".
The parameter of the callback function is the callback trigger. |
|
|
10
|
After event registration
|
11
|
After event deletion
|
12
|
Before start of execution
|
13
|
After break
|
14
|
After CPU reset
|
18
|
After debug tool properties are changed
|
19
|
Before download
|
20
|
After memory or register is changed
|
21
|
After action event (only Printf event)
|
30
|
Before build
|
50
|
After occurrence of specified exception cause code
(after acceptance of exception cause code specified by debugger.Interrupt.Notification)
|
63
|
After period specified by XRunBreak or timer interrupt has elapsed
|
Caution 1. | Hook functions and callback functions are initialized by the following operations. |
- | When a project file is loaded |
- | When a new project file is created |
- | When the active project is changed |
- | When the debugging tool is switched |
- | When Python is initialized |
Caution 2. | Do not include a process that enters an infinite loop in hook functions and callback functions. |
Caution 3. | Do not use the following functions in the hook functions and callback function. |
debugger.ActionEvent, debugger.Breakpoint, debugger.Connect,
debugger.Disconnect, debugger.Download, debugger.Erase, debugger.Go,
debugger.Map, debugger.Next, debugger.Reset, debugger.ReturnOut,
debugger.Run, debugger.Step, debugger.Stop
|
Caution 4. | It is not possible to call debugger.XRunBreak.Set or debugger.Interrupt.SetTimer with different conditions in the hook function (AfterTimer) and callback function (parameter: 63). |
Example 1. | Do not make the following specifications in a hook function. |
def AfterTimer():
debugger.Interrupt.SetTimer(1, TimeType.Ms, True)
debugger.XRunBreak.Set(1, TimeType.Ms, True)
|
Example 2. | Do not make the following specifications in a callback function. |
def pythonConsoleCallback(Id):
if Id = 63:
debugger.XRunBreak.Delete()
debugger.Interrupt.SetTimer(1, TimeType.Ms, True)
debugger.XRunBreak.Set(1, TimeType.Ms, True)
|
Caution 5. | Use the following functions when the hook function is AfterTimer or AfterInterrupt and when the parameter of the callback function is 50 or 63. |
debugger.Address, debugger.GetIORList, debugger.Interrupt, debugger.Memory,
debugger.Register, debugger.Watch, debugger.XRunBreak
|
Note that debugger.Interrupt.SetTimer and debugger.XRunBreak cannot be used when the hook function is AfterTimer or when the parameter of the callback function is 63.
[Example of use]
>>>Hook("E:/TestFile/TestScript/testScriptFile2.py")
|