summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorChristopher Peplin <chris.peplin@rhubarbtech.com>2014-01-03 13:40:02 -0500
committerChristopher Peplin <chris.peplin@rhubarbtech.com>2014-01-03 13:40:02 -0500
commit330358c978ea3d324740a8dba884c4493fa339b8 (patch)
tree405c6f572531e5624bb15da16bc73da99035503e /tests
parent99dd20fc3d6c14d9e8af65264ad712ca6718dcdd (diff)
Split up functions to rx CAN messages for rx and tx of ISO-TP.
Diffstat (limited to 'tests')
-rw-r--r--tests/common.c4
-rw-r--r--tests/test_receive.c20
-rw-r--r--tests/test_send.c7
3 files changed, 15 insertions, 16 deletions
diff --git a/tests/common.c b/tests/common.c
index 554293c9..f9898b32 100644
--- a/tests/common.c
+++ b/tests/common.c
@@ -5,7 +5,7 @@
#include <stdarg.h>
IsoTpShims SHIMS;
-IsoTpHandle HANDLE;
+IsoTpReceiveHandle RECEIVE_HANDLE;
uint16_t last_can_frame_sent_arb_id;
uint8_t last_can_payload_sent[8];
@@ -81,7 +81,7 @@ void can_frame_sent(const uint16_t arbitration_id, const uint8_t* payload,
void setup() {
SHIMS = isotp_init_shims(debug, mock_send_can, mock_set_timer);
- HANDLE = isotp_receive(&SHIMS, 0x2a, message_received);
+ RECEIVE_HANDLE = isotp_receive(&SHIMS, 0x2a, message_received);
memset(last_message_sent_payload, 0, OUR_MAX_ISO_TP_MESSAGE_SIZE);
memset(last_message_received_payload, 0, OUR_MAX_ISO_TP_MESSAGE_SIZE);
memset(last_can_payload_sent, 0, sizeof(last_can_payload_sent));
diff --git a/tests/test_receive.c b/tests/test_receive.c
index 95afb949..1452ed3e 100644
--- a/tests/test_receive.c
+++ b/tests/test_receive.c
@@ -6,7 +6,7 @@
#include <stdarg.h>
extern IsoTpShims SHIMS;
-extern IsoTpHandle HANDLE;
+extern IsoTpReceiveHandle RECEIVE_HANDLE;
extern uint16_t last_can_frame_sent_arb_id;
extern uint8_t last_can_payload_sent;
@@ -28,8 +28,8 @@ extern void setup();
START_TEST (test_receive_empty_can_message)
{
const uint8_t data[CAN_MESSAGE_BYTE_SIZE] = {0};
- fail_if(HANDLE.completed);
- IsoTpMessage message = isotp_receive_can_frame(&SHIMS, &HANDLE, 0x100, data, 0);
+ fail_if(RECEIVE_HANDLE.completed);
+ IsoTpMessage message = isotp_continue_receive(&SHIMS, &RECEIVE_HANDLE, 0x100, data, 0);
fail_if(message.completed);
fail_if(message_was_received);
}
@@ -38,8 +38,8 @@ END_TEST
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(RECEIVE_HANDLE.completed);
+ IsoTpMessage message = isotp_continue_receive(&SHIMS, &RECEIVE_HANDLE, 0x100, data, 1);
fail_if(message.completed);
fail_if(message_was_received);
}
@@ -49,7 +49,7 @@ START_TEST (test_receive_bad_pci)
{
// 4 is a reserved number for the PCI field - only 0-3 are allowed
const uint8_t data[CAN_MESSAGE_BYTE_SIZE] = {0x40};
- IsoTpMessage message = isotp_receive_can_frame(&SHIMS, &HANDLE, 0x2a, data, 1);
+ IsoTpMessage message = isotp_continue_receive(&SHIMS, &RECEIVE_HANDLE, 0x2a, data, 1);
fail_if(message.completed);
fail_if(message_was_received);
}
@@ -58,9 +58,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_if(RECEIVE_HANDLE.completed);
+ IsoTpMessage message = isotp_continue_receive(&SHIMS, &RECEIVE_HANDLE, 0x2a, data, 3);
+ fail_unless(RECEIVE_HANDLE.completed);
fail_unless(message.completed);
fail_unless(message_was_received);
ck_assert_int_eq(last_message_received_arb_id, 0x2a);
@@ -71,7 +71,7 @@ END_TEST
START_TEST (test_receive_single_frame)
{
const uint8_t data[CAN_MESSAGE_BYTE_SIZE] = {0x02, 0x12, 0x34};
- IsoTpMessage message = isotp_receive_can_frame(&SHIMS, &HANDLE, 0x2a, data, 3);
+ IsoTpMessage message = isotp_continue_receive(&SHIMS, &RECEIVE_HANDLE, 0x2a, data, 3);
fail_unless(message.completed);
fail_unless(message_was_received);
ck_assert_int_eq(last_message_received_arb_id, 0x2a);
diff --git a/tests/test_send.c b/tests/test_send.c
index ca1842a6..7944e6ff 100644
--- a/tests/test_send.c
+++ b/tests/test_send.c
@@ -6,7 +6,6 @@
#include <stdarg.h>
extern IsoTpShims SHIMS;
-extern IsoTpHandle HANDLE;
extern void message_sent(const IsoTpMessage* message, const bool success);
@@ -30,7 +29,7 @@ extern void setup();
START_TEST (test_send_empty_payload)
{
uint16_t arbitration_id = 0x2a;
- IsoTpHandle handle = isotp_send(&SHIMS, arbitration_id, NULL, 0, message_sent);
+ IsoTpSendHandle handle = isotp_send(&SHIMS, arbitration_id, NULL, 0, message_sent);
fail_unless(handle.success);
fail_unless(handle.completed);
ck_assert_int_eq(last_message_sent_arb_id, arbitration_id);
@@ -49,7 +48,7 @@ START_TEST (test_send_single_frame)
{
const uint8_t payload[] = {0x12, 0x34};
uint16_t arbitration_id = 0x2a;
- IsoTpHandle handle = isotp_send(&SHIMS, arbitration_id, payload,
+ IsoTpSendHandle handle = isotp_send(&SHIMS, arbitration_id, payload,
sizeof(payload), message_sent);
ck_assert_int_eq(last_message_sent_arb_id, arbitration_id);
fail_unless(last_message_sent_status);
@@ -71,7 +70,7 @@ START_TEST (test_send_multi_frame)
const uint8_t payload[] = {0x12, 0x34, 0x56, 0x78, 0x90, 0x01, 0x23,
0x45, 0x67, 0x89};
uint16_t arbitration_id = 0x2a;
- IsoTpHandle handle = isotp_send(&SHIMS, arbitration_id, payload, sizeof(payload),
+ IsoTpSendHandle handle = isotp_send(&SHIMS, arbitration_id, payload, sizeof(payload),
message_sent);
fail_unless(handle.completed);
fail_if(handle.success);