lishen2 / isotp-c

An implementation of the ISO-TP (ISO15765-2) CAN protocol in C
MIT License
203 stars 77 forks source link

handling multi-frame receive? #16

Closed zerog2k closed 2 years ago

zerog2k commented 4 years ago

Does this library currently handle multi-frame receive? I don't see it providing a user-defined function for something like isotp_user_receive_can which can be polled along with sending flow control messages to receive a full message package over multiple frames.

tictacmenthe commented 3 years ago

It does, check the isotp_on_can_message function. If it is called with all the messages of the frame, isotp_receive will return the full data. In the readme:

            /* Receive your can message yourself */
            ret = can_receive(&id, &data, &len);

            /* If the ID is correct, give it to isotp_on_can_message */
            if (RET_OK == ret && 0x7RR == id) {
                isotp_on_can_message(&g_link, data, len);
            }

            /* Poll link to update receptions and transmissions */
            isotp_poll(&g_link);

            /* If a reception is completed isotp_receive returns ISOTP_RET_OK.
               payload is the reception output buffer
               payload_size is the maximum payload size
               out_size is the actual read size
               */
            ret = isotp_receive(&g_link, payload, payload_size, &out_size);
            if (ISOTP_RET_OK == ret) {
                /* Handle received message */
            }
lishen2 commented 2 years ago

Nice