diff --git a/src/nxslib/nxscope.py b/src/nxslib/nxscope.py index c27d185..fc32c71 100644 --- a/src/nxslib/nxscope.py +++ b/src/nxslib/nxscope.py @@ -143,6 +143,8 @@ def disconnect(self) -> None: if self._connected is True: # stop stream self.stream_stop() + # disable all channels now + self.ch_disable_all(True) # disconnect self._comm.disconnect() self._connected = False @@ -256,6 +258,21 @@ def ch_disable( # write channels configuration self.channels_write() + def ch_disable_all(self, writenow: bool = False) -> None: + """Disable all channels. + + The effects of this method are buffered and will + be applied to the device just before the stream starts + or can be forced to write with writenow flag. + + :param writenow: write channels configuration now + """ + self._comm.ch_disable_all() + + if writenow: + # write channels configuration + self.channels_write() + def ch_divider( self, chans: list[int] | int, div: int, writenow: bool = False ) -> None: diff --git a/tests/test_nxscope.py b/tests/test_nxscope.py index a874bc6..19f91e8 100644 --- a/tests/test_nxscope.py +++ b/tests/test_nxscope.py @@ -240,6 +240,20 @@ def test_nxscope_channels_runtime(): _ = q1.get(block=True, timeout=1) _ = q2.get(block=True, timeout=1) + # configuration not written + nxscope.ch_disable_all() + + assert dev0.data.en is True + assert dev1.data.en is True + assert dev2.data.en is True + + # configuration written + nxscope.ch_disable_all(True) + + assert dev0.data.en is False + assert dev1.data.en is False + assert dev2.data.en is False + # stop stream nxscope.stream_stop()