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

fix(isotp_sock.c): add CAN_ISOTP_WAIT_TX_DONE flag to ISOTP sockets #30

Closed
wants to merge 4 commits into from
Closed

Conversation

muehlke
Copy link

@muehlke muehlke commented May 13, 2024

As of now, an UDS client run on the Linux ISOTP kernel module was not able to recognize a timeout error of a Flow Control frame not arriving in time after a multi-frame request. To fix this, the flag CAN_ISOTP_WAIT_TX_DONE is set on the socket. Otherwise writing the bytes of the SEND buffer to the ISOTP socket would incorrectly return the expected SEND buffer size, creating further problems like e.g. a timeout waiting on the response of the "sent" request, since it was not really sent so the UDS server is not sending a response.

Copy link
Owner

@driftregion driftregion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @muehlke . Please address the feedback and consider adding yourself to AUTHORS.txt

Comment on lines 103 to 105
// setup
client = ENV_TpNew("client");
TPMockLogToStdout();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove these lines. They are not necessary and make the test fail on tp_c

Suggested change
// setup
client = ENV_TpNew("client");
TPMockLogToStdout();

Comment on lines 112 to 114
// teardown
ENV_TpFree(client);

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above, please remove these lines.

Suggested change
// teardown
ENV_TpFree(client);

int main() {
const struct CMUnitTest tests[] = {
// cmocka_unit_test_setup_teardown(TestSendRecv, setup, teardown),
cmocka_unit_test_setup_teardown(TestSendRecvFunctional, setup, teardown),
cmocka_unit_test_setup_teardown(TestISOTPSendLargestSingleFrame, setup, teardown),
cmocka_unit_test_setup_teardown(TestISOTPSendLargerThanSingleFrameFails, setup, teardown),
cmocka_unit_test_setup_teardown(TestISOTPSendRecvMaxLen, setup, teardown),
cmocka_unit_test_setup_teardown(TestISOTPFlowControlFrameTimeout, NULL, NULL),
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use the default setup and teardown

Suggested change
cmocka_unit_test_setup_teardown(TestISOTPFlowControlFrameTimeout, NULL, NULL),
cmocka_unit_test_setup_teardown(TestISOTPFlowControlFrameTimeout, setup, teardown),

// teardown
ENV_TpFree(client);

// -1 is expected as the elapsed 1s timeout raises an error on the ISOTP socket
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make the comment match the assertion

Suggested change
// -1 is expected as the elapsed 1s timeout raises an error on the ISOTP socket
// failure is expected as the elapsed 1s timeout raises an error on the ISOTP socket

muehlke added 4 commits June 14, 2024 15:11
As of now, an UDS client run on the Linux ISOTP kernel module was not able to recognize a timeout error of a Flow Control frame not arriving in time after a multi-frame request. To fix this, the flag CAN_ISOTP_WAIT_TX_DONE is set on the socket. Otherwise writing the bytes of the SEND buffer to the ISOTP socket would incorrectly return the expected SEND buffer size, creating further problems like e.g. a timeout waiting on the response of the "sent"  request, since it was not really sent so the UDS server is not sending a response.
…n a client ISOTP socket with no responding server

With this test it can be assured that by having set the CAN_ISOTP_WAIT_TX_DONE flag
on an ISOTP socket a communication error will be raised after trying to send a multi-frame
request to an UDS server that will not send a FC frame within 1s.
@muehlke muehlke closed this Jun 14, 2024
@muehlke muehlke deleted the patch-1 branch June 14, 2024 13:27
@muehlke
Copy link
Author

muehlke commented Jun 14, 2024

Hi @driftregion, could you please delete this pull request from the repo. I've made a new one #32.

By mistake I committed with the wrong git username and email. I've pushed everything as you mentioned but with the right git username and email.

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.

2 participants