If you are familiar with t scripts, you know that they are based on “hooks”. Hooks are like interrupts. The runtime engine waits for these hooks, then executes the code that is inside its code block. For example, let’s say you need to respond to a CAN message with an ID of 0x200. The t script code would look something like:
When we receive a CAN message with an ID of 0x200, our t script will raise replyFunc() to, say, send a CAN response message, then it will leave the code block when complete. However, each time we receive a message from ID 0x200 we start at the same point. This can make executing a sequence of events challenging.
By implementing a switch/case statement with a global incrementor, we can enter the hook and reference the incrementor, just as you would use a bookmark. We will execute some process, and increment to bookmark before we leave. See the code example below:
So Kvasers’ t script hooks handle an event and the bookmark switch/case approach creates a sequence of events. Reflashing is a perfect example of such a sequence of events. We leverage this simple, yet effective technique to follow the Unified Diagnostic Services (UDS)-prescribed sequence of events to build reflashing tools (I wrote an article about that here, check it out!) and CAN Calibration Protocol (CCP) calibration tools.
If you’d like a template t script of this strategy outlined above, you can download it here. If you’d like Exclusive Origin to design a t script to turn a Memorator into a handheld reflashing or recalibration tool, please contact us!