Repository navigation
cli: keep the mask of inverted --filter arguments - #2182
Open
thomas0829 wants to merge 1 commit into
Open
thomas0829 wants to merge 1 commit into
thomas0829 wants to merge 1 commit into
Conversation
_CanFilterAction ANDed the mask of "<can_id>~<can_mask>" with CAN_ERR_FLAG instead of ~CAN_ERR_FLAG, so the mask was always 0 and the inverted SocketCAN filter blocked every frame. Clear only the error flag, as candump does. Fixes hardbyte#2181
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
CAN_ERR_FLAGfrom the mask of an inverted--filter <can_id>~<can_mask>argument instead of keeping only that bit, so123~7FFgivescan_mask=0x7FFinstead of0.test/test_cli.pyandtest/test_viewer.py, which asserted the old value (0x7F0 & 0x20000000, that is, 0).doc/changelog.d/2181.fixed.rst.Why
With
can_mask=0, the Linux kernel stores the inverted filter ascan_id & 0and never delivers a frame, because(rx_id & 0) != 0is never true.candumpparses the same syntax withcan_mask &= ~CAN_ERR_FLAG, and the--filterhelp text describes the!=match.Validation
python -csnippet from cli: inverted --filter <can_id>~<can_mask> drops the mask #2181 prints0x20000123 0x0onmain(86e70bc) and0x20000123 0x7ffwith this changepytest test/test_cli.py test/test_viewer.py: the updatedtest_add_bus_arguments,test_add_bus_arguments_no_prefixandtest_parse_argsfail onmain(0 != 2032,2047 != 0) and pass herepytest: same results as onmain(885 tests; the 35 that fail in this environment fail identically onmain, and pass when run on their own)black --check .,ruff check can examples doc,pylint can/cli.py can/logger.py can/viewer.py: cleanmypy --python-version 3.12 .: no new errors (the 7 incan/io/mf4.pyalso show onmain)Related Issues / Pull Requests
Type of Change
Checklist
tox).Additional Notes
Tested by parsing only; no SocketCAN device was available. Software filtering in
BusABC._matches_filtersdoes not handleCAN_INV_FILTER, which this change leaves as is.