Port out of range

Hi,

I am trying to read images from two different cameras.
I can read from the camera at port 0.
When attempting to read from the camera on port 1 I get port out of range.

I am running under Ubuntu 20.04.3 LTS 64 bit.
python cvb 1.4
The cameras are connected through a PoE switch

The code snip where it fails looks like this:

    def getDevices(self):

        devices = []
        for i, selector in enumerate(self.camSelectors):
            selName = selector.getSelectedItem()
            if selName != 'None' and selName is not None:
                gdcFile = '{}{}{}'.format(self.getHomeDir(), os.sep, selName)
                Log().info(f'Port {i}, Loading file : {selName}')
                device = cvb.DeviceFactory.open(provider=os.path.join(cvb.install_path(), 'drivers', 'GenICam.vin'), port=i)
                if os.path.isfile(gdcFile):
                    device.node_maps['Device'].load_settings(gdcFile)
                else:
                    Log().warning('Could not find a config file for device: ' + selName)
                devices.append(device)
                #time.sleep(5)

        return devices

In essence, I loop over the selected camera and try to open the one which has a selected configuration file.
The problem occurs in this line:

device = cvb.DeviceFactory.open(provider=os.path.join(cvb.install_path(), 'drivers', 'GenICam.vin'), port=i)

and give me:

device = cvb.DeviceFactory.open(provider=os.path.join(cvb.install_path(), 'drivers', 'GenICam.vin'), port=i)
IndexError: port out of range

Hi @ruben

Im not sure what your selector actually is.
Basically it should be possible to load every camera you have on your system by the way you are trying to.
Only thing to check though is, that the driver is actually configured for each camera (green icon on the right view of the GenICamBrowser).
Also im not sure, if you can simply increment the port for loading.

There was a time :cvb: loaded the driver to port 0 by default. I would assume that this is still the same today, but with the overload of which port to use in the DeviceFactory.open() this should be more convenient.
In past times you hat to load the driver, switch the port of the device and only then were able to load another device (as port 0 was free now).

Maaaaybe you cant call the open() with port 0 and in the next step with port 1 but I have never tried that.
Just try counting you index down and dont forget, that the whole port overload thing is 0 based.

Im pretty sure this will already fix your problem, if not, try the following:


import cvb  

interface_flags = cvb.DiscoverFlags.UpToLevelInterface | cvb.DiscoverFlags.IgnoreGevSD 
all_interfaces = cvb.DeviceFactory.discover_from_root(interface_flags)  

broadcast_flags = cvb.DiscoverFlags.IgnoreVins | cvb.DiscoverFlags.IncludeInaccessible |
cvb.DiscoverFlags.IgnoreGevSD 

all_devices = [] 

for interface in all_interfaces: 
cvb.DiscoveryInformation.set_genapi_feature(interface, "TLInterface", "DisableSubnetMatch", "1") 
cvb.DiscoveryInformation.set_genapi_feature(interface, "TLInterface", "AllowBroadcastDiscoveryResponse", "1") 
    found_devices = cvb.DeviceFactory.discover_from_level(interface.access_token, broadcast_flags) 
    for dev in found_devices: 
        all_devices.append(dev)  

for dev in all_devices: 
    # Check devices access status etc.: 
    # dev.read_property(cvb.DiscoveryProperties.DeviceAccessStatus)  

with cvb.DeviceFactory.open(all_devices[0].access_token) as device: # open first camera found (check accessibility before!) 
# work with camera...

If you are on Linux, remove the IgnoreGevSD tag…

Cheers
Chris

Thanks for the reply Chris.

We fixed it quite easily by putting a sleep(2) between the opening of the ports.
Instead of using open, we used open_port.

Ruben

Well that sounds like a workaround, as long as this is fine for you thats great.