Camera connection state changed event usage


I am developing a program in Ubuntu by using Python.

I try to use register_connection_state_changed_event like below

     interface_flags = cvb.DiscoverFlags.UpToLevelInterface | cvb.DiscoverFlags.IgnoreGevFD
        all_interfaces = cvb.DeviceFactory.discover_from_root(interface_flags)
        broadcast_flags = cvb.DiscoverFlags.IgnoreVins | cvb.DiscoverFlags.IncludeInaccessible | cvb.DiscoverFlags.IgnoreGevFD

        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:

        ids = cvb.DeviceFactory.discover_from_root(cvb.DiscoverFlags.IgnoreVins) =[0].access_token)
        except Exception as e:
            print(f"ex :{str(e)}")

By running this I get this exception : std::exception but I reach the call back code once.

Could you please help me with usage of register_connection_state_changed_event ?

PS : Tried the code below but I do not know which node name I should use to get the node and pass it to call back:


Thank you in advance

Hi @Fatemeh

Sorry for the late response due to the vacation season. The Following code block shows how to do connection monitoring in Python:

import os 
import time 
import cvb 
def connection_changed(dev: cvb.Device): 
    print("Connection state changed: ") 

device =, "drivers", ""), port=0) 

while True: 

1 Like