Developer Blog

03/06/2021 by Elsa Carlsson

SAE J2534 (Part III): Getting Started with Kvaser and SAE J2534

This Developer Blog is the third of a 3-part series taking a look at SAE J2534. This series introduces SAE J2534 (including it’s multiple editions), describes how to use the 2004 API, and then provides instruction on getting started with Kvaser and J2534.

Getting Started with Kvaser and SAE J2534

The first step is to think about which protocol(s) you’ll be using, and then look up the Protocol Basics and Sequence of Operation for said protocol(s). This is because the protocols are fundamentally different, and you will need to know how to treat each one to get your desired result.

If you ever get confused about why the API works a certain way, or which standards document you should consult History and Concept for how we got here.

To get access to Kvaser’s J2534 DLL you need to install the CANlib drivers, making sure “J2534 driver” is selected to be installed (which is the default).

unnamed (3)

This will both install the J2534 DLL and set up the Windows registry in accordance with the standard. If you wish to configure the DLL you do so through Kvaser’s J2534 Options Tool. This is most easily accessed via the Kvaser Device Guide, under the “Tools” menu:

unnamed (4)

This program allows you to do things such as enable logging and where the J2534 should put the log file (if enabled). This file contains information such as which DLL you’re using, what channels you connect, and all error statuses — information which Kvaser Support will find very useful if you end up needing to contact us.

Snapshot 2021-03-22 13.49.27
unnamed (5)

The J2534 Options Tool will also show you where the J2534 DLL has been installed (as that is configurable in the Windows Registry; all the options in this tool are saved into the registry). This can be useful if you want to load the DLL directly without going through the Windows Registry.

And next to the installed DLL is the very important readme-file.

The first thing to do now is to check the readme file. If you installed the CANlib drivers to the default path then the readme can be found at C:\Program Files\Kvaser\Drivers\j2534api-readme.txt (otherwise it will be in the corresponding location). This readme contains up-to-date information about the modifications Kvaser has made to the standard in order for the API to fit cleanly on top of CANlib.

The information in the readme is important, and not included in these articles because it is all subject to change as Kvaser implements new features and receives customer feedback.

Then you’re ready to load the DLL into your favorite environment and start developing. Remember to check all status codes returned by the API, and if any errors are indicated call PassThruGetLastError() to get a more detailed description of what went wrong.

You will now be able to use your favorite Kvaser device to diagnose vehicles using any “Generic PC running a Win32 (or indeed Win64) Operating System”!

car

Definitions

  • ISO-TP
    The Transport Protocol defined in 15765-2:2011, without the support for CAN FD which was introduced in 15765-2:2016. Sometimes ambiguously called simply ISO 15765-2 or ISO 15765.
  • ISO-TP FD
    The Transport Protocol defined in 15765-2:2016 (including the support for CAN FD).
  • CAN
    The Controller Area Network as described in ISO 11898, a blanket term for both CAN 2.0 and CAN FD.
  • CAN 2.0
    The “classic” CAN with up to eight bytes of data and no support for bit rate switching.
  • CAN FD
    CAN Flexible Data rate protocol that supports longer data than CAN 2.0 as well as bit rate switching.
  • J2534
    A family of standards that specify the Pass-Thru device and the Pass-Thru API used to communicate to the device via a J2534 DLL.
  • J2534 DLL
    The DLL provided by an interface manufacturer, which conforms to the Pass-Thru API.
  • Pass-Thru API
    The API of all J2534 DLLs, which the vehicle manufacturer can use regardless of which company’s J2534 DLL is actually in use.
  • Pass-Thru device
    A specific type of device standardized by J2534, which has an accompanying J2534 DLL.

Standards

  • J2534-1:2004
    https://www.sae.org/standards/content/j2534/1_200412/
  • J2534-1:2015
    https://www.sae.org/standards/content/j2534/1_201510/
  • J2534-2:2006
    https://www.sae.org/standards/content/j2534/2_200603/
  • J2534-2:2010
    https://www.sae.org/standards/content/j2534/2_201010/
  • J2534-2:2019
    https://www.sae.org/standards/content/j2534/2_201901/
  • ISO 15765-2:2011
    https://www.iso.org/standard/54499.html
  • ISO 15765-2:2016
    https://www.iso.org/standard/66574.html
  • ISO 11898
    https://www.iso.org/advanced-search/x/title/status/P/docNumber/11898/docPartNo/docType/0/langCode/ics/currentStage/true/searchAbstract/true/stage/stageDateStart/stageDateEnd/committee/sdg
Author Image

Elsa Carlsson

In memory of Elsa Carlsson who worked for Kvaser between 2017-2021, restructuring the Python wrapper and rewriting Kvaser's J2534 DLL. Elsa was a creative, thoughtful colleague and talented software engineer. She is missed by many.