Interrupt routines are blocks of script (like procedures with no parameters) that run simultaneously with the main script and are triggered (called) automatically. When any of those predefined events inside the Interrupt option happen, the corresponding Interrupt routines are called by the Script Engine and run simultaneously with the main script.
Interrupt routines should be relatively small in size and short in duration in to avoid disruptions in running the main script. Therefore, the number of instructions is limited and only a few commands are supported inside Interrupts. Because of the way the Interrupts are executed and to avoid memory corrupts, Global variable updates are not allowed. They can, however, be used inside Interrupts, but care must be taken as their value may change inside the Generation block during the execution of the Interrupt routine.
Interrupt Events
Three different types of events are supported for Interrupts. All of these resources can be used for any Interrupt routine. If more than one event type is used for an Interrupt, it will be called when either of those events occur.
-
Frame Events: Frame events can be used to trigger an Interrupt routine when a Frame pattern is received (similar to Frame event in GenOptions).
-
Symbol: Symbol events can be used to trigger an Interrupt routine when a special Symbol is received (similar to Symbol event in GenOptions).
-
Orderedset Mask: Orderedset Mask events can be used to trigger an Interrupt routine when any ordered set in the selected list on the specified DWORD is received.
Interrupt Syntax
Any of the Interrupt routines can be defined after (or before) Generation block in any order.
Generation {
# Generation Block here
}
Interrupt_A {
# Interrupt Routine A can be defined here
}
Interrupt_B {
# Interrupt Routine B can be defined here
}
Interrupt_C {
# Interrupt Routine C can be defined here
}
Interrupt_D {
# Interrupt Routine D can be defined here
}
Valid Commands Inside Interrupts
Send Commands
-
SendData (Including Send and SendCRC commands)
-
Send Symbol
-
Frame
-
SendFrame
-
LRF statements
-
Local Variable Definition/Assignment
-
Local Variable Operations
-
Global Variable Operations (Read-Only)
-
Following Functions:
-
InjectSyncHeaderError
-
InjectRSFECError
-
ReverseByteOrder
-
Exit
-
If-Else expressions
-
Known Limitations of Interruption
Limited Commands
Only the specified commands in Valid Commands Inside Interrupts are allowed to be used inside Interrupts. Interrupt routines should also be as minimal as possible, with no complex logic, to avoid interference with the main script logic.
Using Variables
Each Interrupt has its own resources for temporary and local variables and they cannot be shared between different Interrupts or Generation block.
To avoid memory corrupts, Global variable updates are not allowed, but they can be used inside Interrupts. However, this not encouraged as their value might change anytime inside the Generation block during the execution of the Interrupt routine; thus making its behavior unpredictable.
Limited number of resources
The Block size and temporary variable resources are much more limited for Interrupts compared to generation script. Using large blocks or complex logic is discouraged as it may interfere with the execution of Generation block.
Send/Receive Buffer
The send buffer, if prioritized based on the Interrupt ID (from A to D), and Generation block have the lowest priority for sending data on the line.
Receive buffer is accessible to Interrupts and Generation block simultaneously (when using LRF expressions).