Getting Started with CANlib

Download and install Kvaser CANlib SDK and Driver

With the driver and SDK installed, you can get started right away. Virtual channels installed with the driver lets you test your code without yet having an actual Kvaser interface.

Download page

Use the samples

In the samples folder of the SDK installation, you will find a number of samples to get you started.

For the beginner, a good choice to get started is the C# tutorial. It covers everything you need to get started. They are installed in the \Samples\Getting Started folder where you installed CANlib. There are tutorials for other languages, but the C# is the most comprehensive.

Read the CANlib tutorial Here

Developer blog

When you need further information on topics, please take a look at our developer blog.

There you will find in-depth articles on a number of subjects, to help you take your software to the next level.

Before you start

Here we will go through some things that might be good to know before you start programming with Canlib.

Importing Canlib

In order to program using Canlib, you will need to add a reference to the library. To do this in Visual Studio, follow these steps:

  1. Right click on your project in the Solution Explorer and select โ€œAdd referenceโ€. In some versions of Visual Studio, you need to right click the References folder under your project instead.
  2. Right click on your project and select โ€œPropertiesโ€ (Hotkey: Alt+Enter). Then select Build. Under โ€œConfigurationsโ€, select โ€œAll Configurationsโ€ and under โ€œTarget platformโ€ select either โ€œx86โ€ or โ€œx64โ€.
  3. Press โ€œBrowseโ€ and browse to the correct version of the CanlibCLSNET.dll. It will be in the โ€œCanlib\dotnetโ€ directory, but which file to use depends on your target platform and .NET version. If youโ€™re building your project for 32 bit processors, select the x86 directory. If youโ€™re building for 64 bit processors, select x64. Next, you need to pick the correct dll for your version of the .NET Framework. If you use a version older than 4.0, select fw11 (x86 only), otherwise select fw40. In this directory, you will find the .dll you need.
  4. You should now be able to write a program by importing the CanlibCSLNET namespace. (using CanlibCSLNET)

CanKing

Kvaser CanKing is a CAN bus monitor which you can use to test your programs. You can find it here.

CanKing can be used for both sending and receiving messages to and from your own programs.

Finding more information

For detailed information about the Canlib API, please see the help file . If you want to know more about a method or some other part of the API while programming in Visual Studio, you can right click on it in your code and select โ€œGo To Definitionโ€.