Developer Blog

13/04/2020 by Bryan Hennessy

Beginner’s Guide to Using Kvaser’s Virtual Drivers

If you are interested in developing a Controller Area Network (CAN) project from home using tools available to you today, Kvaser and our partners can help. Kvaser’s CAN interfaces and dataloggers work with one universal driver that includes a Virtual CAN Driver.

This Virtual CAN driver is used by tools to monitor and transmit CAN data, and with a little imagination you can start a CAN development project, continue an existing development, and learn more about CAN, all within the confines of your home, with tools that are readily available.

Here, I will give an example of how this can be accomplished. Using Kvaser CanKing, the free bus monitor software available on the Kvaser web site, along with the Kvaser Drivers for Windows, available from the same place, I can transmit and receive CAN messages through the two virtual ports available in the driver.

NOTE: Virtual Drivers are supported in both Windows and Linux environments.

For a deeper look at configuring virtual devices, virtual channels, and virtual busses, see the Developer Blog:

How to use Kvaser Virtual Device Channel and Bus >> 

Full tutorial text with screenshots:

Virtual Driver Tutorial

Download and install Kvaser Drivers for Windows, available here:

Download and install Kvaser CanKing, available at the same link.

Start CanKing and select Template from the first window.

After selecting OK, you will see the Template selection window. Select 2 CAN channels within this window leading to two CAN windows appearing on your desktop.. One Kvaser driver supports a maximum of two virtual channels, so this is the only selection that makes sense for now, since you need a minimum of two channels to pass data.


Five windows should open on your desktop, the Kvaser CanKing window, two CAN Channel windows, a Select Formatter window, and the Output Window. If your configuration is different you can go to the View menu and manually turn these five windows on. You’ll also need the Timed Transmission and History List windows, so turn these on as well. I like to arrange the windows on my Desktop so I can see everything, and the locations are logical. Here’s how my Desktop looks now:


Make sure you select the Virtual CAN Driver in both CAN 1 and CAN 2 windows, found under CAN Channels. One should say 0 – Kvaser Virtual CAN Driver, and the other should say 1 – Kvaser Virtual CAN Driver. Both channels should also have the same Bus Configuration information. All this should be set by default. Now select Start Run in your Kvaser CanKing window. This will turn on both Virtual channels and start communication. Now we create a message.

Go up to the Message menu in the top right corner, and select Universal, or just use the shortcut Ctrl+U. The window that will open will look like this:


This CAN Message 1 window is where we’re going to select a CAN message to send on our virtual CAN bus. Plug a simple CAN Identifier into the top box, say $0F0, then type a number between 1 and 8 into the DLC box. I like to use 8 to send a full frame of data. Now click on Randomize Data in the lower right corner of the window. My window now looks like this:


We are now all set to transmit the data. Click Send in your CAN Message 1 window. If you followed the steps above you should see two messages in your Output Window, and one in your History List window. The Output Window shows one message as Transmitted, and the same message as Received on the other channel. What we just did was to send our CAN message from one virtual channel to a second virtual channel. Here is what’s at the top of my Output Window:


You can see that this is the same randomized data selected in the CAN Message 1 window, with the CAN Identifier that I selected, transmitted from channel 0 and received on channel 1.

Let’s send one more message with a different Data Length Cade (DLC). Go back to the CAN Message 1 window and change the CAN Identifier, I’ll use $050 for the new identifier. Now change the DLC to 3. Click the Randomize Data button again, then click Send. Another message should be transmitted from Channel 0 and received on Channel 1, this time with only three data bytes. You can see this below in my CAN Message 1 window and my Output Window:


Now we are set up to go to step two of this training and use the History List window to send repeating CAN data frames. Your Timed Transmission window should still be open on your desktop. If not, you can go to the View menu and open it. I filled in my Timed Transmission window for 1000ms and Cyclic Transmission Mode:


Next, I looked at my History List window and could see the two original messages I transmitted and received through the virtual channels:


If you now select Send All in the History List window, you will see that the messages you created are pulled from the History List and transmitted on the virtual CAN bus according the parameters set in your Timed Transmission window. Here is what my Output Window now shows:


This is just an example of what can be done with the Kvaser Virtual CAN drivers and Kvaser CanKing. Other tasks that can be performed with the software you have are:

  • Develop an example .dbc file as it would be used to decode any CAN data (J1939, NMEA 2000®, or CANOpen), and then put it to work by generating some data with CanKing and seeing if the decode goes correctly. Search for J1939 DBC Files and find this link if you want to learn more about these before working with .dbc files.
  • Download and install a trial version of a partner’s CAN analysis tool and get to know it by sending and receiving data with it, through your virtual CAN bus.
  • Download and install Kvaser CANlib SDK and develop a PC based application that accesses a CAN bus, then test your application through the virtual CAN driver.

Further Reading:

Dev Blog Article: How to use Kvaser Virtual Device Channel and Bus

  • A deeper look at using registry edits to configure your system for 16 virtual channels.
Author Image

Bryan Hennessy

Bryan Hennessy is the Technical Partner Manager for Kvaser AB, with a background in J1939, CAN diagnostics, marine electronics, and semiconductors.