diff options
author | Romain Forlot <romain.forlot@iot.bzh> | 2017-05-02 17:52:11 +0200 |
---|---|---|
committer | Romain Forlot <romain.forlot@iot.bzh> | 2017-05-02 17:52:11 +0200 |
commit | 0242c26c2f5dc96387bca7efb118364c800f4ee7 (patch) | |
tree | ba0a67a78004a45afd158a3ca3fb01c6fc012e06 /CAN-binder/libs/uds-c/tests/common.c | |
parent | 3102ec9ce009d0f28355c5b7df9c5bd5013e6e75 (diff) | |
parent | ca20db3dd978871bbb9f01f3c862b510c03d1dc4 (diff) |
Add 'CAN-binder/libs/uds-c/' from commit 'ca20db3dd978871bbb9f01f3c862b510c03d1dc4'
git-subtree-dir: CAN-binder/libs/uds-c
git-subtree-mainline: 3102ec9ce009d0f28355c5b7df9c5bd5013e6e75
git-subtree-split: ca20db3dd978871bbb9f01f3c862b510c03d1dc4
Diffstat (limited to 'CAN-binder/libs/uds-c/tests/common.c')
-rw-r--r-- | CAN-binder/libs/uds-c/tests/common.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/CAN-binder/libs/uds-c/tests/common.c b/CAN-binder/libs/uds-c/tests/common.c new file mode 100644 index 0000000..fd1e4b2 --- /dev/null +++ b/CAN-binder/libs/uds-c/tests/common.c @@ -0,0 +1,43 @@ +#include <uds/uds.h> +#include <stdint.h> +#include <stdio.h> +#include <stdlib.h> +#include <stdarg.h> +#include <string.h> + +DiagnosticShims SHIMS; + +uint32_t last_can_frame_sent_arb_id; +uint8_t last_can_payload_sent[8]; +uint8_t last_can_payload_size; +bool can_frame_was_sent; + +DiagnosticResponse last_response_received; +bool last_response_was_received; + +void debug(const char* format, ...) { + va_list args; + va_start(args, format); + vprintf(format, args); + printf("\r\n"); + va_end(args); +} + +bool mock_send_can(const uint32_t arbitration_id, const uint8_t* data, + const uint8_t size) { + can_frame_was_sent = true; + last_can_frame_sent_arb_id = arbitration_id; + last_can_payload_size = size; + if(size > 0) { + memcpy(last_can_payload_sent, data, size); + } + return true; +} + +void setup() { + SHIMS = diagnostic_init_shims(debug, mock_send_can, NULL); + memset(last_can_payload_sent, 0, sizeof(last_can_payload_sent)); + can_frame_was_sent = false; + last_response_was_received = false; +} + |