Ixxat USB-to-CAN v4 API for .Net, Cannot Connect to VciServer for Unity Game Engine

I’m writing an application that reads from a controller attached to Ixxat’s USB-to-CAN. This is a C# application. I’m new to the API, but I understand that the starting point is to get an instance of the VciServer object via code like the following:

// Get a reference to the server.
IVciServer server = IVciServer.Instance();

However, this line throws the following exception:

ArgumentNullException: Argument cannot be null.
Parameter name: path1
System.IO.Path.Combine (System.String path1, System.String path2) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.IO/Path.cs:112)
Ixxat.Vci4.VciServer.LoadServer ()
Ixxat.Vci4.VciServer.Instance ()
Test.Start () (at Assets/Ixxat USB-to-CAN/Test.cs:13)

Can someone assist? I cannot find anything about how to handle this, and I can’t move forward until I clear this hurdle.


I will look into this and then reach out with more information. Thanks!



I checked with a colleague and he had the following questions/suggestions.

"1.1. Would you please tell me which USB-to-CAN do you use?
USB-to-CAN, USB-to-CAN compact, USB-to-CAN II or USB-to-CAN V2?

1.2. Would you please tell me which VCI V4 do you use? VCI V4.0.507.0?

1.3. Would you please tell me if the USB-to-CAN successfully run with the canAnalyser V3 mini?

  1. Would you please try with the
    deviceManager = VciServer.Instance().DeviceManager;
    instead of the
    IVciServer server = IVciServer.Instance();
    as in the CanConNet.cs programming example?

  2. Would you please tell me if the USB-to-CAN V2 successfully run with the VCI V4 C#.NET programming example?
    c:\Users\Public\Documents\HMS\IXXAT VCI 4.0\Samples\dotnet\Samples.sln
    c:\Users\Public\Documents\HMS\IXXAT VCI 4.0\Samples\dotnet\CANConNet\CanConNet.cs"


Hi Nick! Thanks for responding.

I don’t have all the requested details in front of me as I write this, but
I can still answer a few of those right now.

Yes, I can read the USB-to-CAN from the analyzer program provided. That
works just fine.

Yes, the sample does work to read the device as well. I was able to write a
similar program to meet my needs. It runs fine in Visual Studio.

Where I encountered the problem I originally wrote about was when I tried
to read the USB-to-CAN from within the Unity3D game engine. It is there
that I recieve the indicated error. To try and replicate, download Unity3D
and write a C# script that does some basic operation.

To get around my immediate problem, I wrote a simple socket server-client
program to bridge the gap. My C# application reads the USB-to-CAN, then
sends the data via a socket to be read by the client script in Unity3D. I
wish this wasn’t a necessary step and I could utilize the VCI libraries
directly in Unity, but I’m on a tight deadline for a project so this
workaround will have to do for the moment. However, if you can replicate
the problem and determine the root cause with a fix, I’m all ears!

I’ll reply with answers to your other questions as I’m able. Thanks for
your attention.

  • Joe


I provided your latest post to my colleagues, and they actually have an example,

“Here you will find a .NET via NPL access demo. It shows (as example) how to access VCI V3 device not via VCINET class. It uses direct access to the VCINPL.DLL.
This work on Unity gaming engine environment.”

VCI_NET_NPL_Demo_running_also_with-Unity3D.zip (790.6 KB)



Thanks so much Nick.

I won’t be able to try this immediately as I had to use a socket-based
workaround to meet a deadline, and I also no longer have access to the
hardware involved. However, there will be a second iteration of that
project so at some point in the future I will be able to try your
suggestion. For now, I’m keeping it on deck. I’ll let you know how it works
out on a future date.

Thanks for your help!

Ok, thank you for the update.


Hi there,

Recently I came across this post when looking for a way to communicate with a CAN with Unity3d.

The demo project provided here has helped me tremendously, thanks for that! However, I don’t seem to be able to send messages from Unity3d to the CAN bus with data in them.

The example message I’m sending has an identifier value of 0 and two data bytes, both of value 1.

The message being transmitted has an identifier only, but no data.

If you have any tips or pointers to guide me into the right direction, I’d be a very happy man.

The code I’m using is the following:

/// <summary>
/// Transmits a CAN message.
/// </summary>
public void TransmitMessage()
	CANMSG pCanMsg = new CANMSG();
	// Set the message identifier
    pCanMsg.dwMsgId = 0;

	// Set the message data bytes
	pCanMsg.abDataArray = new byte[8];
	byte dataByte = Convert.ToByte (63);
	pCanMsg.abDataArray.SetValue(dataByte, 0);

	// Set the message time (delayed transmission)
	pCanMsg.dwTime = 0;

	// Send the message
    int result = mVciV4NplAccess.CanChannelSendMessage(mHandleCANChannel, 100, ref pCanMsg);
    Debug.Log("Transmission result: " + result);




I will have to ask a colleague about this, I will let you know what they say.




I received this feedback,

Please set the DLC as in the below attached programming example:

static void TransmitMessage()
  CANMSG pCanMsg = new CANMSG();

  // no transmission delay
  pCanMsg.dwTime = 0;

  // CAN identifier 0x100
  pCanMsg.dwMsgId = 0x100;

  // 3 data bytes
  pCanMsg.abDataArray = new byte[8];
  pCanMsg.abDataArray[0] = 0x55;
  pCanMsg.abDataArray[1] = 0xAA;
  pCanMsg.abDataArray[2] = 0xFF;

  // Set DLC (data length code), this is the lower 4 bits of the bFlags
  pCanMsg.uMsgInfo.bFlags = 0x03;

   * Here the original flags from the file CANtype.h
     #define CAN_MSGFLAGS_DLC     0x0F // data length code
     #define CAN_MSGFLAGS_OVR     0x10 // data overrun flag
     #define CAN_MSGFLAGS_SRR     0x20 // self reception request
     #define CAN_MSGFLAGS_RTR     0x40 // remote transmission request
     #define CAN_MSGFLAGS_EXT     0x80 // frame format (0=11-bit, 1=29-bit)

  // now set the self reception flag to see our own message in the receive window
  pCanMsg.uMsgInfo.bFlags |= 0x20;   // self reception request

  // if you like you can send alos Extended 29 bit Identifiers
  // pCanMsg.uMsgInfo.bFlags |= 0x80;  // frame format (0=11-bit, 1=29-bit)

  mVciV3NplAccess.CanChannelSendMessage(mHandleCANChannel, 100, ref pCanMsg);