If you want to get the most out of your Kvaser USBcan Pro interface or Kvaser Memorator Pro interface and data loggers, t programs (or scripts) are the way to go. These simple-to-develop programs allow you to customize your Kvaser device to do just about anything but make the tea.
Put simply, t programming allows a technical user to write a C-like program 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, CANlib SDK, the user can be up and running in minutes, designing their own specific functions for their Kvaser device.
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 Kvaser’s CANlib SDK to build, download, and run your t programs 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 program flow is determined by events such as incoming CAN messages – t programs support functions that respond to events, such as timers, floating point calculations, structures, recursion and file access.
What can I use t for?
A Kvaser Memorator Pro or USBcan Pro can be used to accomplish many tasks with the aid of a simple or more complex t program. Here are some of the most popular applications that Kvaser staff have encountered:
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.
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.
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 its event driven programming language, this programmable device can act as a standalone ECU simulator, no matter how advanced the ECU requiring simulation.
A t program 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.
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 program running on a CAN interface to access the ECU directly also circumvents any latency caused by the PC interface. Another advantage is that with multiple 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.
The CAN Calibration Protocol (CCP) and Universal Measurement and Calibration Protocol (XCP) protocols for reading measurement data and writing parameters to ECUs are commonly used during development, testing and in-vehicle calibration. Kvaser’s Technical Associate, Accurate Technologies Inc. (ATI), writes t programs for Memorator that provide customers with a ‘tailor-made’ approach to CCP/XCP. ATI locks the execution of their t program to the Memorator device’s serial number, thus protecting customers’ CCP/XCP solutions, including the Seed and Key parameters.
Higher Layer Protocols
Support for various higher layer protocols such as J1939 can be implemented in Kvaser Eagle or Memorator Pro via custom-built t programs. 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 is FREE and includes TRX, an IDE for writing and controlling t programs, 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.
Posts from the Developer’s Blog to get you started learning t programming:
Getting Started with t Programming (“Hello World”) by Martin Henriksson
Adding script and triggers to a configuration by Magnus Carlsson
t script Roadblock Resolutions: 3 t script Resources You Can’t Do Without by Judson Brundage
t script Roadblock Resolutions: Implementing a Program Flow Using Hooks by Judson Brundage