Search code examples
c#canoe

Read connected Vector VN boxes with C#


does anyone know a way, how I can access the Vector Hardware Setup via VS in C# and read the connected VN boxes (name and driver)?

Because I want to read all connected VN boxes on my pc and will show the VN names in a combobox.

thanks a lot


Solution

  • This should be doable via the Vector XL Driver Library. It provides a native and .NET wrapper library which allows you to access Vector HW.

    1. Download/reference the .NET library.
    2. Code below will give you the channels on all devices. You should be able to back track from there to get distinct devices by serial number (excerpt from samples provided by Vector):
        using vxlapi_NET;
        //...
    
        // Driver access through XLDriver (wrapper)
        XLDriver CANDemo = new XLDriver();
    
        // Open XL Driver
        XLDefine.XL_Status status = CANDemo.XL_OpenDriver();
        Console.WriteLine("Open Driver       : " + status);
    
        // Get XL Driver configuration
        status = CANDemo.XL_GetDriverConfig(ref driverConfig);
        // Display channel count
          Console.WriteLine("Channels found    : " + driverConfig.channelCount);
    
    
        // Display channel count
        Console.WriteLine("Channels found    : " + driverConfig.channelCount);
    
    
        // Display all found channels
        for (int i = 0; i < driverConfig.channelCount; i++) {
            Console.WriteLine("\n                   [{0}] " + driverConfig.channel[i].name, i);
            Console.WriteLine("                    - Channel Mask    : " + driverConfig.channel[i].channelMask);
            Console.WriteLine("                    - Transceiver Name: " + driverConfig.channel[i].transceiverName);
            Console.WriteLine("                    - Serial Number   : " + driverConfig.channel[i].serialNumber);
        }
    

    Output:

    Open Driver       : XL_SUCCESS
    Get Driver Config : XL_SUCCESS
    DLL Version       : 20.30.14
    Channels found    : 12
    
                       [0] VN1630A Channel 1
                        - Channel Mask    : 1
                        - Transceiver Name: LINpiggy 7269mag
                        - Serial Number   : 5292
    
                       [1] VN1630A Channel 2
                        - Channel Mask    : 2
                        - Transceiver Name: CANpiggy 1050mag (Highspeed)
                        - Serial Number   : 5292
    
                       [2] VN1630A Channel 3
                        - Channel Mask    : 4
                        - Transceiver Name: On board CAN 1051cap(Highspeed)
                        - Serial Number   : 5292
    
                       [3] VN1630A Channel 4
                        - Channel Mask    : 8
                        - Transceiver Name: On board CAN 1051cap(Highspeed)
                        - Serial Number   : 5292
    
                       [4] VN1630A Channel 5
                        - Channel Mask    : 16
                        - Transceiver Name: On board D/A IO 1021
                        - Serial Number   : 5292
    
                       [5] VN1630A Channel 1
                        - Channel Mask    : 32
                        - Transceiver Name: LINpiggy 7269mag
                        - Serial Number   : 38935
    
                       [6] VN1630A Channel 2
                        - Channel Mask    : 64
                        - Transceiver Name: CANpiggy 1057Gcap (Highspeed)
                        - Serial Number   : 38935
    
                       [7] VN1630A Channel 3
                        - Channel Mask    : 128
                        - Transceiver Name: On board CAN 1051cap(Highspeed)
                        - Serial Number   : 38935
    
                       [8] VN1630A Channel 4
                        - Channel Mask    : 256
                        - Transceiver Name: On board CAN 1051cap(Highspeed)
                        - Serial Number   : 38935
    
                       [9] VN1630A Channel 5
                        - Channel Mask    : 512
                        - Transceiver Name: On board D/A IO 1021
                        - Serial Number   : 38935
    
                       [10] Virtual Channel 1
                        - Channel Mask    : 1024
                        - Transceiver Name: Virtual CAN
                        - Serial Number   : 100
    
                       [11] Virtual Channel 2
                        - Channel Mask    : 2048
                        - Transceiver Name: Virtual CAN
                        - Serial Number   : 100