-
-
Notifications
You must be signed in to change notification settings - Fork 17
/
scantool_bits.c
106 lines (89 loc) · 2.7 KB
/
scantool_bits.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
/* stuff copied from freediag scantool.c just to make this compile */
#include "diag.h"
#include "diag_err.h"
#include "diag_l2.h"
#include "scantool_cli.h"
#define RQST_HANDLE_WATCH 1 /* Watching, add timestamp */
#define RQST_HANDLE_DECODE 2 /* Just decode what arrived */
const int _RQST_HANDLE_WATCH = RQST_HANDLE_WATCH; //Watching: add timestamp
const int _RQST_HANDLE_DECODE = RQST_HANDLE_DECODE; //Just decode what arrived
/* garbage to make freediag cli compile */
const struct cmd_tbl_entry test_cmd_table[] = {
{ "up", "up", "Return to previous menu level",
cmd_up, 0, NULL},
{ "quit","quit", "Exit program",
cmd_exit, CLI_CMD_HIDDEN, NULL},
{ "exit", "exit", "Exit program",
cmd_exit, 0, NULL},
{ NULL, NULL, NULL, NULL, 0, NULL}
};
const struct cmd_tbl_entry vag_cmd_table[] = {
{ "up", "up", "Return to previous menu level",
cmd_up, 0, NULL},
{ "quit","quit", "Exit program",
cmd_exit, CLI_CMD_HIDDEN, NULL},
{ "exit", "exit", "Exit program",
cmd_exit, 0, NULL},
{ NULL, NULL, NULL, NULL, 0, NULL}
};
const struct cmd_tbl_entry dyno_cmd_table[] = {
{ "up", "up", "Return to previous menu level",
cmd_up, 0, NULL},
{ "quit","quit", "Exit program",
cmd_exit, CLI_CMD_HIDDEN, NULL},
{ "exit", "exit", "Exit program",
cmd_exit, 0, NULL},
{ NULL, NULL, NULL, NULL, 0, NULL}
};
const struct cmd_tbl_entry v850_cmd_table[] = {
{ "up", "up", "Return to previous menu level",
cmd_up, 0, NULL},
{ "quit","quit", "Exit program",
cmd_exit, CLI_CMD_HIDDEN, NULL},
{ "exit", "exit", "Exit program",
cmd_exit, 0, NULL},
{ NULL, NULL, NULL, NULL, 0, NULL}
};
void l2raw_data_rcv(UNUSED(void *handle), struct diag_msg *msg) {
/*
* Layer 2 call back, just print the data, this is used if we
* do a "read" and we haven't yet added a L3 protocol
*/
diag_printmsg(stderr, msg, 0);
return;
}
/* dummy func, we're not using J1979 */
void j1979_data_rcv(void *handle, struct diag_msg *msg) {
(void) handle;
(void) msg;
return;
}
/* dummy func, we're not using J1979 */
struct diag_l3_conn;
int l3_do_send(struct diag_l3_conn *d_conn, void *data, size_t len, void *handle) {
(void) d_conn;
(void) data;
(void) len;
(void) handle;
fprintf(stderr, "Error : L3 send code neutralized\n");
return 0;
}
/* identicopy of scantool.c */
int
l2_do_send(struct diag_l2_conn *d_conn, void *data, size_t len, void *handle)
{
struct diag_msg msg={0};
int rv;
if (len > 255) {
return DIAG_ERR_GENERAL;
}
/* Put in src/dest etc, L2 may override/ignore them */
msg.src = global_cfg.src;
msg.dest = global_cfg.tgt;
msg.len = len;
msg.data = (uint8_t *)data;
diag_l2_send(d_conn, &msg);
/* And get response(s) */
rv = diag_l2_recv(d_conn, 300, l2raw_data_rcv, handle);
return rv;
}