diff --git a/src/controller/python/chip/ChipDeviceCtrl.py b/src/controller/python/chip/ChipDeviceCtrl.py index 03a5cccf524b33..f7f2f328b93559 100644 --- a/src/controller/python/chip/ChipDeviceCtrl.py +++ b/src/controller/python/chip/ChipDeviceCtrl.py @@ -318,7 +318,7 @@ def DeviceAvailableCallback(device, err): nonlocal returnDevice nonlocal deviceAvailableCV with deviceAvailableCV: - returnDevice = device + returnDevice = c_void_p(device) deviceAvailableCV.notify_all() if err != 0: print("Failed in getting the connected device: {}".format(err)) @@ -331,11 +331,11 @@ def DeviceAvailableCallback(device, err): # The callback might have been received synchronously (during self._ChipStack.Call()). # Check if the device is already set before waiting for the callback. - if returnDevice == c_void_p(None): + if returnDevice.value == None: with deviceAvailableCV: deviceAvailableCV.wait() - if returnDevice == c_void_p(None): + if returnDevice.value == None: raise self._ChipStack.ErrorToException(CHIP_ERROR_INTERNAL) return returnDevice diff --git a/src/controller/python/test/test_scripts/base.py b/src/controller/python/test/test_scripts/base.py index 5aab196a1ac088..031d2280500fa8 100644 --- a/src/controller/python/test/test_scripts/base.py +++ b/src/controller/python/test/test_scripts/base.py @@ -343,11 +343,14 @@ def run(self): "OnOff", "OnOff", nodeid, endpoint, 1, 10) changeThread = _conductAttributeChange( self.devCtrl, nodeid, endpoint) + # Reset the number of subscriptions received as subscribing causes a callback. + handler.subscriptionReceived = 0 changeThread.start() with handler.cv: while handler.subscriptionReceived < 5: # We should observe 10 attribute changes handler.cv.wait() + changeThread.join() return True except Exception as ex: self.logger.exception(f"Failed to finish API test: {ex}")