mirror of https://github.com/rusefi/isotp-c.git
Only mark handle as completed when fully received.
This commit is contained in:
parent
fe20a273bb
commit
e3637d97ec
|
@ -76,6 +76,8 @@ IsoTpMessage isotp_receive_can_frame(IsoTpShims* shims, IsoTpHandle* handle,
|
|||
message.payload = payload;
|
||||
message.size = payload_length;
|
||||
message.completed = true;
|
||||
handle->success = true;
|
||||
handle->completed = true;
|
||||
isotp_handle_single_frame(handle, &message);
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -101,6 +101,11 @@ IsoTpMessage isotp_receive_can_frame(IsoTpShims* shims, IsoTpHandle* handle,
|
|||
const uint16_t arbitration_id, const uint8_t data[],
|
||||
const uint8_t size);
|
||||
|
||||
// TODO perhaps this makes more sense as 2 functions:
|
||||
// bool isotp_continue_send()
|
||||
// IsoTpMessage isotp_continue_receive()
|
||||
// but both with the same args
|
||||
|
||||
/* Public: Change the timeout for waiting on an ISO-TP response frame.
|
||||
*
|
||||
* If this function is not used, the conventional 100ms is used by default.
|
||||
|
|
|
@ -20,7 +20,7 @@ IsoTpHandle isotp_receive(IsoTpShims* shims,
|
|||
|
||||
IsoTpHandle handle = {
|
||||
success: false,
|
||||
completed: true,
|
||||
completed: false,
|
||||
receive_handle: receive_handle,
|
||||
type: ISOTP_HANDLE_RECEIVING
|
||||
};
|
||||
|
|
|
@ -28,6 +28,7 @@ extern void setup();
|
|||
START_TEST (test_receive_wrong_id)
|
||||
{
|
||||
const uint8_t data[CAN_MESSAGE_BYTE_SIZE] = {0};
|
||||
fail_if(HANDLE.completed);
|
||||
IsoTpMessage message = isotp_receive_can_frame(&SHIMS, &HANDLE, 0x100, data, 1);
|
||||
fail_if(message.completed);
|
||||
fail_if(message_was_received);
|
||||
|
@ -47,7 +48,9 @@ END_TEST
|
|||
START_TEST (test_receive_single_frame_empty_payload)
|
||||
{
|
||||
const uint8_t data[CAN_MESSAGE_BYTE_SIZE] = {0x00, 0x12, 0x34};
|
||||
fail_if(HANDLE.completed);
|
||||
IsoTpMessage message = isotp_receive_can_frame(&SHIMS, &HANDLE, 0x2a, data, 3);
|
||||
fail_unless(HANDLE.completed);
|
||||
fail_unless(message.completed);
|
||||
fail_unless(message_was_received);
|
||||
ck_assert_int_eq(last_message_received_arb_id, 0x2a);
|
||||
|
|
Loading…
Reference in New Issue