BOROSOFTWAREAll work →
scantool/scantool_cli.h 131 lines
1#ifndef _SCANTOOL_CLI_H_
2#define _SCANTOOL_CLI_H_
3/*
4 * freediag - Vehicle Diagnostic Utility
5 *
6 *
7 * Copyright (C) 2001 Richard Almeida & Ibex Ltd ([email protected])
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 *
23 *************************************************************************
24 *
25 *
26 * Mostly ODBII Compliant Scan Tool (as defined in SAE J1978)
27 *
28 * CLI routines
29 *
30 */
31
32#if defined(__cplusplus)
33extern "C" {
34#endif
35
36#include <stdbool.h>
37#include <stdint.h>
38#include <stdio.h>
39
40#include "libcli.h"
41
42
43/** Find either a $home/.<progname>.rc or ./<progname>.ini (in order of preference)
44 *
45 * @return a filename (must be free'd by caller) if either was found, otherwise NULL.
46 */
47char *find_rcfile(void);
48
49
50/** start CLI
51 *
52 * @param inistcript: optional
53 */
54void scantool_cli(const char *prompt, const char *initscript, const struct cmd_tbl_entry *cmdtable);
55
56void wait_enter(const char *message);
57int pressed_enter(void);
58
59
60/**
61 * Decimal/Octal/Hex to integer routine
62 * formats:
63 * [-]0[0-7] : octal
64 * [-]0x[0-9,A-F,a-f] : hex
65 * [-]$[0-9,A-F,a-f] : hex
66 * [-][0-9] : dec
67 * Returns 0 if unable to decode.
68 */
69int htoi(char *buf);
70
71
72extern int diag_cli_debug; /* debug level */
73extern FILE *global_logfp; /* Monitor log output file pointer */
74void log_timestamp(const char *prefix);
75
76
77
78/** Global parameters set by user interface **/
79
80/* struct global_cfg contains all global parameters */
81extern struct globcfg {
82 bool units; /* English(1) or Metric(0) display */
83
84 uint8_t tgt; /* u8; target address */
85 uint8_t src; /* u8: source addr / tester ID */
86 bool addrtype; /* Address type, 1 = functional */
87 unsigned int speed; /* ECU comms speed */
88
89 int initmode; /* Type of bus init (ISO9141/14230 only) */
90 int L1proto; /* L1 (H/W) Protocol type */
91 int L2proto; /* L2 (S/W) Protocol type; value of ->diag_l2_protocol. */
92 int L2idx; /* index of that L2 proto in struct l2proto_list[] */
93
94 const char *l0name; /* L0 interface name to use */
95 //struct diag_l0_device *dl0d; /* L0 device to use */
96} global_cfg;
97
98
99enum globstate {
100 //specify numbers because some code checks (for global_state >= X) etc.
101 STATE_IDLE=0, /* Idle */
102 STATE_WATCH=1, /* Watch mode */
103 STATE_CONNECTED=2, /* Connected to ECU */
104 STATE_L3ADDED=3, /* Layer 3 protocol added on Layer 2 */
105 STATE_SCANDONE=4, /* J1978/9 Scan Done, so got J1979 PID list */
106}; //only for global_state !
107extern enum globstate global_state;
108
109extern struct diag_l0_device *global_dl0d;
110
111extern const char *progname;
112
113
114/* Sub menus */
115
116extern const struct cmd_tbl_entry set_cmd_table[];
117extern int set_init(void);
118extern void set_close(void);
119
120extern const struct cmd_tbl_entry debug_cmd_table[];
121extern const struct cmd_tbl_entry test_cmd_table[];
122extern const struct cmd_tbl_entry diag_cmd_table[];
123extern const struct cmd_tbl_entry vag_cmd_table[];
124extern const struct cmd_tbl_entry v850_cmd_table[];
125extern const struct cmd_tbl_entry dyno_cmd_table[];
126
127#if defined(__cplusplus)
128}
129#endif
130#endif /* _SCANTOOL_CLI_H_ */
131