t Script

Known also as t programs and the t programming language, see Knowledge Base 

If you want to get the most out of your Kvaser USBcan Pro interface or Kvaser Memorator Pro interface and data loggers, t scripts are the way to go. These simple-to-develop scripts allow you to customize your Kvaser device to do just about anything but make the tea.

Put simply, t scripts allow users to write scripts in a C-like language that takes control of the embedded processor within the Kvaser device, and makes use of many internal routines that perform common and specific functions related to the available hardware. The ‘on CanMessage’ hook is an example, allowing the user to quickly instruct the Kvaser device to perform specific actions when a defined CAN message is received, creating the possibility for quick, responsive CAN solutions. By downloading and installing Kvaser’s free development software development kit, the Kvaser SDK, one can be up and running in minutes, designing custom functions for their Kvaser device.

Why t?

Kvaser created a language that would allow developers to use an editor of their choice to adapt the device to their needs. Alternatively, you can use TRX, an Integrated Development Environment (IDE) included with the Kvaser SDK to build, download, and run your t scripts on a device.

The t programming language is compiled on the developer’s PC into efficient byte code for execution on t-capable hardware i.e. the Kvaser USBcan Pro or Memorator Pro series. As an event-driven language—where the script flow is determined by events such as incoming CAN messages—t scripts support functions that respond to events, such as timers, floating point calculations, structures, recursion and file access.

Download the PDF t Programming Benefits and Applications

What can I use t for?

A Kvaser Memorator Pro or USBcan Pro can be used to accomplish many tasks with the aide of a simple or more complex t script. Here are some of the most popular applications that Kvaser staff have encountered:

Filtering

t can be used to change the messages recorded, based on the state of a system. For example, when a system is in startup mode, everything must be recorded, and recording stopped when normal operation begins. If a user then wanted to record messages only when the temperature reading of a thermostat exceeds a certain value, but some of the messages they only wanted once every second because they are transmitted too frequently.

Diagnostics

With advanced logging and statistics collection capabilities, Kvaser’s Memorator Pro data loggers can be programmed to actively interrogate an ECU, requesting further information from it, depending on the response.

ECU Simulation

There are many situations in which a system requires testing, but one or several ECUs are not available to run tests. For example, in the early stages of the powertrain and vehicle design cycle, when an ECU is being designed but other ECUs are missing; during design and production of associated parts and perhaps even during servicing. A ‘virtual’ ECU that can mimic the signals produced by the real one can save considerable time.

Memorator Pro is an ideal host for simple or complex ECU simulation programs. With t‘s event-driven design, this programmable device can act as a standalone ECU simulator, no matter how advanced the ECU requiring simulation.

Gateway/Bridge

A t script can transform t-capable Kvaser hardware into a gateway or bridge between two CAN networks. Whilst other devices on the market can do this, what differentiates t-capable Kvaser hardware is the ability to use filters to screen out certain messages and, if necessary, inject faults. For example, an engineer can use the Kvaser Memorator Pro as a bridge between two different CAN networks that filters out certain types of message, or injects new values into certain types of CAN messages. E.g. CANopen to J1939 gateway sample code.

t can also be used to encrypt the gateway between two CAN networks, by implementing CAN Security Encryption locally on the t-capable Kvaser device.

Flash Programming

t-capable Kvaser hardware can run scripts to handle flash reprogramming, with the advantage being that there is no need for any interaction from a PC, which is how flash reprogramming is carried out today. Using a t script running on a CAN interface to access the ECU directly also circumvents any latency caused by the PC interface. Another advantage is that with multi-channel Pro devices, the channels can be manipulated independently, so multiple nodes can be reflashed at the same time. With the in-built encryption option, manufacturers that use t-capable Kvaser hardware for flash programming can be assured that their proprietary ECU access codes remain fully secured.

ECU Calibration

The CAN Calibration Protocol (CCP) and Universal Measurement and Calibration Protocol (XCP) for reading measurement data and writing parameters to ECUs are commonly used during development, testing and in-vehicle calibration. Kvaser’s technical associates create custom scripts for the Memorator that offer a tailored approach to CCP/XCP. These scripts are secured by locking them to the specific serial number of the Memorator device, ensuring the protection of customers’ CCP/XCP solutions, including Seed and Key parameters.

Higher Layer Protocols

Support for various higher layer protocols such as J1939 can be implemented in the  Memorator via custom-built t scripts. Customer requests for particular protocol stacks will be passed to appropriate Kvaser technical partners. E.g. NMEA node simulation.

What do I need to get started with t?

Get Your Interface

Kvaser t-enabled hardware such as the USBcan Pro 5xHS CAN interface, or the Kvaser Memorator Pro 2xHS and Memorator Pro 5xHS CAN interface and dataloggers. For a complete list, visit our Product page.

CANlib SDK
Download CANlib

CANlib SDK is FREE and includes TRX, an IDE for writing and controlling t scripts, plus a sample library to help you get started. The SDK also contains more complex examples, such as partial support for ISO15765 and KWP2000, and how to simulate a wave generator node, amongst others.

Download the t Programming Language Guide

Download the t Programming Language guide for additional help and advice. The guide describes the language and provides code snippets to enhance understanding.

If You Run Into Problems...

If you encounter difficulties, don’t hesitate to contact Kvaser Support. Don’t forget that if you don’t have the necessary software resources in-house to work with t, we can put you in touch with a Kvaser Technical Associate who can develop simple or complex custom programs for you. Please contact our Support for details.

Still Have Questions?

Please contact our Support team by email at support@kvaser.com.