Update doc revision and pdf cover.
[apps/low-level-can-service.git] / libs / uds-c / tests / common.c
1 #include <uds/uds.h>
2 #include <stdint.h>
3 #include <stdio.h>
4 #include <stdlib.h>
5 #include <stdarg.h>
6 #include <string.h>
7
8 DiagnosticShims SHIMS;
9
10 uint32_t last_can_frame_sent_arb_id;
11 uint8_t last_can_payload_sent[8];
12 uint8_t last_can_payload_size;
13 bool can_frame_was_sent;
14
15 DiagnosticResponse last_response_received;
16 bool last_response_was_received;
17
18 void debug(const char* format, ...) {
19     va_list args;
20     va_start(args, format);
21     vprintf(format, args);
22     printf("\r\n");
23     va_end(args);
24 }
25
26 bool mock_send_can(const uint32_t arbitration_id, const uint8_t* data,
27         const uint8_t size) {
28     can_frame_was_sent = true;
29     last_can_frame_sent_arb_id = arbitration_id;
30     last_can_payload_size = size;
31     if(size > 0) {
32         memcpy(last_can_payload_sent, data, size);
33     }
34     return true;
35 }
36
37 void setup() {
38     SHIMS = diagnostic_init_shims(debug, mock_send_can, NULL);
39     memset(last_can_payload_sent, 0, sizeof(last_can_payload_sent));
40     can_frame_was_sent = false;
41     last_response_was_received = false;
42 }
43