Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The method set_filters doesn’t work sometimes #1708

Open
Cecilia979 opened this issue Dec 22, 2023 · 4 comments
Open

The method set_filters doesn’t work sometimes #1708

Cecilia979 opened this issue Dec 22, 2023 · 4 comments
Labels

Comments

@Cecilia979
Copy link

Describe the bug

I used the method set_filters to receive the messages of my specified ID,but the first few messages were not what I expected.

To Reproduce

with can.interface.Bus(bustype='vector', channel=2, bitrate=500000,data_bitrate=2000000,app_name="CANoe",fd=True,) as bus:
    bus.set_filters([{"can_id": 0x1b1, "can_mask": 0x7FF, "extended": False}])
    while True:
        msg = bus.recv()
        print("recv",msg)

0x1b1 was the only ID that I expect,but I got others such as 0x3ea,0x335 at the beginning.

Expected behavior

I expect to receive the specified messages

Additional context

OS and version: Win10
Python version: 3.8
python-can version:4.3.1
python-can interface/s (if applicable):
image
Vector / canoe

@Cecilia979 Cecilia979 added the bug label Dec 22, 2023
@hartkopp
Copy link
Collaborator

Does it generally look like that the interface is enabled BEFORE the filters are applied?

@grant-allan-ctct
Copy link
Contributor

Could it be related to #1413 and a general problem of receive buffers not necessarily being flushed when a filter is applied?

@Cecilia979
Copy link
Author

Does it generally look like that the interface is enabled BEFORE the filters are applied?

It seems to be the problem! Because generally speaking, only the first few messages will not be what I expected, while the rest are expected

@Cecilia979
Copy link
Author

Cecilia979 commented Dec 26, 2023

Could it be related to #1413 and a general problem of receive buffers not necessarily being flushed when a filter is applied?

I have read this 1413 issue, and it is indeed similar. But in this issue the device is kvaser, while I am using vector(appname canoe). And I didn't find the flush_rx_buffer function in the source code. There is only flush_tx_buffer. So in fact, I still don't quite understand how to solve this problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants