diff options
author | Romain Forlot <romain.forlot@iot.bzh> | 2017-06-20 10:24:05 +0000 |
---|---|---|
committer | Romain Forlot <romain.forlot@iot.bzh> | 2017-06-20 10:24:05 +0000 |
commit | 32e25cbca210a359b09768537b6f443fe90a3070 (patch) | |
tree | 3309794c15d8a8f8e9c1c08cad072ee1378813ba /libs/uds-c/tests/common.c | |
parent | 76c43dec62b2e21cd6446360c00d4fe6b437533f (diff) |
Separation Generator to a dedicated repo
Change-Id: Id94831651c3266861435272a6e36c7884bef2c45
Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'libs/uds-c/tests/common.c')
-rw-r--r-- | libs/uds-c/tests/common.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/libs/uds-c/tests/common.c b/libs/uds-c/tests/common.c new file mode 100644 index 00000000..fd1e4b2c --- /dev/null +++ b/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; +} + |