BOROSOFTWAREAll work →
scantool/diag_l2_iso14230.h 103 lines
1#ifndef _DIAG_L2_ISO14230_H_
2#define _DIAG_L2_ISO14230_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 * Diag
26 *
27 * L2 driver for ISO14230-2 layer 2
28 *
29 */
30
31#include <stdbool.h>
32#include <stdint.h>
33
34#include "diag.h"
35
36/*
37 * ISO 14230 specific data
38 */
39struct diag_l2_14230 {
40 uint8_t initype; /* init type : FAST/SLOW/CARB */
41
42 uint8_t srcaddr; /* Src address used */
43 uint8_t dstaddr; /* Dest address used (for connect) */
44 int modeflags; /* 14230-specific Flags; see below */
45
46 enum {
47 STATE_CLOSED=0, /* Established comms */
48 STATE_CONNECTING=1, /* Connecting */
49 STATE_ESTABLISHED=2, /* Established */
50 } state;
51
52 bool first_frame; /* First frame flag, used mainly for
53 monitor mode when we need to find
54 out whether we see a CARB or normal
55 init */
56 bool monitor_mode; /* if set, expect possible spurious 0x00 bytes caused by fastinit break */
57
58 uint8_t rxbuf[MAXRBUF]; /* Receive buffer, for building message in */
59 int rxoffset; /* Offset to write into buffer */
60};
61
62// ******* flags for ->modeflags :
63//(these are set in 14230_startcomms() according to init type and keybytes received)
64
65// ISO14230_SHORTHDR (for iso14230) : if set, the ECU supports address-less
66// headers; this is set according to the keybytes received during StartComms.
67// By default we send fully addressed headers (iso14230 5.2.4.1)
68#define ISO14230_SHORTHDR 0x01
69
70//ISO14230_LONGHDR : if set, we can send headers with the address bytes.
71// Set according to the keybytes. If this and SHORTHDR are set, we
72// send addressless headers by default.
73#define ISO14230_LONGHDR 0x2
74
75//ISO14230_LENBYTE: If set, tell the iso14230 code to always use messages
76// with a length byte. This is primarily for SSF14230 - the Swedish vehicle
77// implementation of ISO14230, but is set if required by the StartComms keybytes.
78//If FMTLEN and LENBYTE are set, then we choose the most adequate.
79#define ISO14230_LENBYTE 0x4
80
81//ISO14230_FMTLEN: if set, we can send headers with the length encoded in
82// the format byte. (iso14230)
83#define ISO14230_FMTLEN 0x8
84
85//ISO14230_FUNCADDR : if set, functional addressing (instead of phys) is used.
86#define ISO14230_FUNCADDR 0x10
87
88//ISO14230_IDLE_J1978 : use SID 1 PID 0 keep-alive messages instead of the normal
89//TesterPresent SID.
90#define ISO14230_IDLE_J1978 0x20
91
92
93
94
95#if defined(__cplusplus)
96extern "C" {
97#endif
98
99#if defined(__cplusplus)
100}
101#endif
102#endif /* _DIAG_L2_ISO14230_H_ */
103