Catching missing Flow Control Frame during data transmission
This issue was opened after an exchange of emails with @hartkopp
@hartkopp
Extract of the e-mail sent toI had a question concerning the behavior when sending a multi-frame packet. When I (client side) send a large chunk of data to the server (ECU), and the server does not send a Flow Control frame back to the client, the write(2)
operation does not return any clue about this misbehaving transaction (no error returned, and the number of bytes sent corresponds to the size of the packet).
I wanted to know if there is a way to know when the client enters in such a state.
I digged into the examples but did not found such a use-case.
@hartkopp
extract of the reply fromWhen there's no FC we run into a timeout here:
https://elixir.bootlin.com/linux/v5.11.10/source/net/can/isotp.c#L751
I wanted to know if there is a way to know when the client enters in such a state.
Good point. Usually you catch these errors by monitoring for a timeout on application(!) level as ISO-TP is an unreliable datagramm protocol anyway (like UDP).
Btw. there is a 'blocking write' feature with the CAN_ISOTP_WAIT_TX_DONE flag. This only returns from the write call when either the transmission is completed OR there has been a problem (e.g. timeout).
In the 'problem' case the sk_error is set.
But looking at the code here ...
https://elixir.bootlin.com/linux/v5.11.10/source/net/can/isotp.c#L955
... it always seems to return the original length value. And I did not test how the sk_error is propagated to the user.
Hm - maybe we can both take a look at this.
Did you try CAN_ISOTP_WAIT_TX_DONE?
Without CAN_ISOTP_WAIT_TX_DONE the errors can not be assigned to a specific PDU.