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

Refactor flush_tx_queue for VectorBus #1636

Merged
merged 5 commits into from
Oct 8, 2023
Merged

Refactor flush_tx_queue for VectorBus #1636

merged 5 commits into from
Oct 8, 2023

Conversation

deronek
Copy link
Contributor

@deronek deronek commented Jul 17, 2023

In VectorBus class, there's an implementation of flush_tx_buffer relying on xlCanFlushTransmitQueue function of the XL driver. However, this function is a no-op for devices other than XL family, which are discontinued. This means that the library does not support flushing the TX buffer for any Vector devices currently available on the market.
(https://cdn.vector.com/cms/content/products/XL_Driver_Library/Docs/XL_Driver_Library_Manual_EN.pdf)

My implementation of flush_tx_buffer consists of “sending” a dummy message with overrun/highprio flag set. The Vector interface will flush the TX queue after receiving a request to send this message.

Tested on VN5610A, for both FD and non-FD bus. I think it's a good idea to check this on other Vector devices, especially on XL family, to make sure that the implementation works for them all. In our use case, the flush is called after XL_ERR_QUEUE_IS_FULL is raised (e.g. when sending a ton of messages on a dead bus). In previous implementation, any next send request will raise this error if the bus is still dead, because the flush was a no-op. In my implementation, next send requests will not raise an error (until it fills up again).

@zariiii9003
Copy link
Collaborator

That's interesting, is that behavior documented somewhere? Or did you talk to Vector support maybe?

@deronek
Copy link
Contributor Author

deronek commented Jul 18, 2023

That's interesting, is that behavior documented somewhere? Or did you talk to Vector support maybe?

The behavior of xlCanFlushTransmitQueue being a no-op outside XL family is documented in the XL driver library manual linked in the first post.

image

The behavior of the message flags triggering TX queue flush is documented beside them in the same document.

image
image

Regarding the issues, I will fix them today. Unfortunately, I don't think a test for this functionality can be written, since I don't think we can directly access the TX queue to check its content.

Implementation cannot be tested due to Vector TX queue being not accessible
@deronek
Copy link
Contributor Author

deronek commented Jul 18, 2023

Issues with tests and formatting were fixed. I'm open to suggestions on how to test this functionality programmatically.

Additionally, I noticed that my implementation will actually send a message with ID = 0, DLC = 0 and no data. I'm also looking for confirmation whether this will not be an issue in some use cases. I will also add this information to the method documentation.
Below was captured with live CAN bus, VN5610A with receive_own_messages=True.

Timestamp: 1689684485.573268    ID:      000    S Tx                DL:  0                                Channel: 0

@deronek
Copy link
Contributor Author

deronek commented Aug 1, 2023

Docstring updated. I also added unit tests for this function with the mocked bus, similar to the test that was for the previous implementation.

@zariiii9003 zariiii9003 merged commit e3d912b into hardbyte:develop Oct 8, 2023
28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants