OpenPort with vin-driver and order of ports

I am trying to communicate with two camera’s using two instances of the same program where I can set the port I want to connect to.

TryOpenPort code
var scannerPort = int.Parse(ScannerPortTextBox.Text);
DeviceFactory.TryOpenPort("GenICam.vin", scannerPort, out Device device)

When I first connect to port 1, then with the second instance to port 0, this works. But when I first connect to port 0, then to port 1 with the second instance it returns false (device=null).

I think there is something I’m overlooking here?

Hi @Laurens

first of all I want to say sorry for the late response!

When loading the :cvb: vin driver, port 0 gets automatically loaded before it switches to the desired port.
Since opening a specific port twice isn’t possible (at least if you do it from different processes), it makes sense, that you can’t load the driver, if you already opened port 0 before. To fix this, you need to adjust the GenICam.ini file. It is located at %CVB%Drivers. Simply enable the following flag:

AutoSwitchEnable=1

All it does, is letting the driver check if the port, it currently wants to load, is already in use, and if so, it changes to the next port or as in your case: to the desired port.

Alternatively you can use the new :cvb: discovery. You will find a short tutorial on how to use it in this post: https://forum.commonvisionblox.com/t/exception-during-discovery/318/8?u=rtp_derahs

2 Likes

The path is not correct or has changed. I found GenICam.ini in folder “c:\ProgramData\STEMMER IMAGING\Common Vision Blox\Drivers” or %CVBDATA%Drivers or %CVBCONFIG%Drivers.

1 Like

Hi @Peter

No, it has always been %CVBDATA%
Thank you for pointing that out! :slight_smile:

weeeeeeellll…

that is my chance to nit-pick :stuck_out_tongue_winking_eye:
In fact the file used to be located in %CVB%\Drivers up until Windows XP. With Windows Vista File System Virtualization and UAC on C:\Program Files kicked in and it no longer was a good idea to store the configuration there, so we found a new spot for it in the location C:\ProgramData\STEMMER IMAGING\Common Vision Blox and to make it less fussy added %CVBDATA%. This was introduced in CVB 10.00.000 which was the first version to actually run properly on Windows Vista. However, 10.x and later still used to install the file to %CVB%\Drivers when installed on a Windows XP machine…

1 Like