Repository navigation
Unify listen-only mode into can.Bus(listen_only=...) - #2149
Merged
Merged
Conversation
zariiii9003
force-pushed
the
listen-only-split-v3
branch
4 times, most recently
from
November 29, 2026 01:47
81084ba to
ae4f810
Compare
…c listen-only options
zariiii9003
force-pushed
the
listen-only-split-v3
branch
from
November 29, 2026 21:24
ae4f810 to
563a541
Compare
This was referenced Nov 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary of Changes
This adds one portable
listen_onlyoption tocan.Bus/BusABC. It replaces the different listen-only switches each interface had before.listen_onlyargument oncan.BusandBusABC.__init__.BusABC.listen_onlyproperty. It can also be set at runtime onpcanandsystec, andThreadSafeBusforwards it.can.cli.add_bus_arguments(listen_only_arg=...).--listen-only/--no-listen-onlyoncan.loggerandcan.viewer.cantact,kvaser,nixnet,pcan,seeedstudio,slcan,systec,vector,virtual.listen_only=Truecheck inspects the constructor signatures, so plugins need no changes.listen_onlyis accepted.CanInterfaceNotImplementedErrorinstead of silently opening in normal mode.DeprecationWarningattributed to the caller, and raisesValueErrorif it contradictslisten_only):cantact:monitorkvaser:driver_modeseeedstudio: the"silent"and"loopback_and_silent"operation modespcan/systec: thestateargument and settingbus.statecan.logger:--active/--passiveCanInitializationError:vector/kvaserwithout init access,kvasercontrollers without silent mode, and PCAN-LAN devices.kvaser's silentdriver_modenow takes effect withsingle_handle=False, because it is applied to the handle that has init access.can.logger --activeno longer raisesNotImplementedError.can.logger --passivenow works on every interface that supports listen-only mode, not onlypcanandsystec.seeedstudiooperation_modenow raisesValueErrorbefore the serial port is opened, instead of aKeyErrorafterwards.doc/bus.rst.pcan,seeedstudioandsystecinterface pages.doc/internal-api.rst.Before / after (the same script run on
mainand on this branch, default warning filters):mainBus("virtual", listen_only=True).send(msg)CanOperationError: Cannot send in listen-only modebus.listen_onlyAttributeErrorTrueBus("udp_multicast", listen_only=True)CanInterfaceNotImplementedError: UdpMulticastBus does not support listen-only modeBus("udp_multicast", listen_only=False)Bus("cantact", monitor=True)demo.py:9: DeprecationWarning: The 'monitor' argument is deprecated …, andbus.listen_only is TrueRelated Issues / Pull Requests
Type of Change
monitor,driver_mode, seeedstudio silent modes,state/bus.state,--active/--passive)Checklist
tox).Additional Notes
listen_only=Trueon an interface without support now raises instead of being ignored.vector, an explicitlisten_only=Falsenow requests init access and sets normal mode. It raises if a channel without init access is not already in normal mode. The defaultNoneleaves the channel as it was.listen_only=False(from an argument, a config file or the environment) is accepted by every interface, including plugins that don't know the argument.doc/changelog.d/2149.{added,changed,deprecated,fixed}.rst.test_bus,test_cli,test_load_config,test_logger,test_viewer,back2back_test, plus cantact, kvaser, pcan, seeedstudio, slcan, systec, vector and virtual).🤖 Generated with AI