forked from miikasyvanen/FastECU
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJ2534_tatrix_linux.h
308 lines (262 loc) · 9.64 KB
/
J2534_tatrix_linux.h
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
#ifndef J2534_TATRIX_LINUX_H
#define J2534_TATRIX_LINUX_H
////////////////
// Protocol IDs
////////////////
// J2534-1
#define J1850VPW 1
#define J1850PWM 2
#define ISO9141 3
#define ISO14230 4
#define CAN 5
#define ISO15765 6
#define SCI_A_ENGINE 7 // OP2.0: Not supported
#define SCI_A_TRANS 8 // OP2.0: Not supported
#define SCI_B_ENGINE 9 // OP2.0: Not supported
#define SCI_B_TRANS 10 // OP2.0: Not supported
// J2534-2
#define CAN_CH1 0x00009000
#define J1850VPW_CH1 0x00009080
#define J1850PWM_CH1 0x00009160
#define ISO9141_CH1 0x00009240
#define ISO9141_CH2 0x00009241
#define ISO9141_CH3 0x00009242
#define ISO9141_K ISO9141_CH1
#define ISO9141_L ISO9141_CH2 // OP2.0: Support for ISO9141 communications over the L line
#define ISO9141_INNO ISO9141_CH3 // OP2.0: Support for RS-232 receive-only communications via the 2.5mm jack
#define ISO14230_CH1 0x00009320
#define ISO14230_CH2 0x00009321
#define ISO14230_K ISO14230_CH1
#define ISO14230_L ISO14230_CH2 // OP2.0: Support for ISO14230 communications over the L line
#define ISO15765_CH1 0x00009400
/////////////
// IOCTL IDs
/////////////
// J2534-1
#define GET_CONFIG 0x01
#define SET_CONFIG 0x02
#define READ_VBATT 0x03
#define FIVE_BAUD_INIT 0x04
#define FAST_INIT 0x05
#define CLEAR_TX_BUFFER 0x07
#define CLEAR_RX_BUFFER 0x08
#define CLEAR_PERIODIC_MSGS 0x09
#define CLEAR_MSG_FILTERS 0x0A
#define CLEAR_FUNCT_MSG_LOOKUP_TABLE 0x0B // OP2.0: Not yet supported
#define ADD_TO_FUNCT_MSG_LOOKUP_TABLE 0x0C // OP2.0: Not yet supported
#define DELETE_FROM_FUNCT_MSG_LOOKUP_TABLE 0x0D // OP2.0: Not yet supported
#define READ_PROG_VOLTAGE 0x0E // OP2.0: Several pins are supported
// J2534-2
#define SW_CAN_NS 0x8000 // OP2.0: Not supported
#define SW_CAN_HS 0x8001 // OP2.0: Not supported
// Tactrix specific IOCTLs
#define TX_IOCTL_BASE 0x70000
// OP2.0: The IOCTL below supports application-specific functions
// that can be built into the hardware
#define TX_IOCTL_APP_SERVICE (TX_IOCTL_BASE+0)
#define TX_IOCTL_SET_DLL_DEBUG_FLAGS (TX_IOCTL_BASE+1)
#define TX_IOCTL_DLL_DEBUG_FLAG_J2534_CALLS 0x00000001
#define TX_IOCTL_DLL_DEBUG_FLAG_ALL_DEV_COMMS 0x00000002
#define TX_IOCTL_SET_DEV_DEBUG_FLAGS (TX_IOCTL_BASE+2)
#define TX_IOCTL_DEV_DEBUG_FLAG_USB_COMMS 0x00000001
#define TX_IOCTL_SET_DLL_STATUS_CALLBACK (TX_IOCTL_BASE+3)
#define TX_IOCTL_GET_DEVICE_INSTANCES (TX_IOCTL_BASE+4)
/////////////////
// Pin numbering
/////////////////
#define AUX_PIN 0 // aux jack OP2.0: Supports GND and adj. voltage
#define J1962_PIN_1 1 // OP2.0: Supports GND and adj. voltage
#define J1962_PIN_2 2 // J1850P OP2.0: Supports 5V and 8V
#define J1962_PIN_3 3 // OP2.0: Supports GND and adj. voltage
#define J1962_PIN_4 4 // GND
#define J1962_PIN_5 5 // GND
#define J1962_PIN_6 6 // CAN
#define J1962_PIN_7 7 // K OP2.0: Supports GND
#define J1962_PIN_8 8 // OP2.0: Supports reading voltage
#define J1962_PIN_9 9 // OP2.0: Supports GND and adj. voltage
#define J1962_PIN_10 10 // J1850M OP2.0: Supports GND
#define J1962_PIN_11 11 // OP2.0: Supports GND and adj. voltage
#define J1962_PIN_12 12 // OP2.0: Supports GND and adj. voltage
#define J1962_PIN_13 13 // OP2.0: Supports GND and adj. voltage
#define J1962_PIN_14 14 // CAN
#define J1962_PIN_15 15 // L OP2.0: Supports GND
#define J1962_PIN_16 16 // VBAT OP2.0: Supports reading voltage
#define PIN_VADJ 17 // internal OP2.0: Supports reading voltage
////////////////////////////////
// Special pin voltage settings
////////////////////////////////
#define SHORT_TO_GROUND 0xFFFFFFFE
#define VOLTAGE_OFF 0xFFFFFFFF
/////////////////////////////////////////
// GET_CONFIG / SET_CONFIG Parameter IDs
/////////////////////////////////////////
// J2534-1
#define DATA_RATE 0x01
#define LOOPBACK 0x03
#define NODE_ADDRESS 0x04 // OP2.0: Not yet supported
#define NETWORK_LINE 0x05 // OP2.0: Not yet supported
#define P1_MIN 0x06 // J2534 says this may not be changed
#define P1_MAX 0x07
#define P2_MIN 0x08 // J2534 says this may not be changed
#define P2_MAX 0x09 // J2534 says this may not be changed
#define P3_MIN 0x0A
#define P3_MAX 0x0B // J2534 says this may not be changed
#define P4_MIN 0x0C
#define P4_MAX 0x0D // J2534 says this may not be changed
#define W0 0x19
#define W1 0x0E
#define W2 0x0F
#define W3 0x10
#define W4 0x11
#define W5 0x12
#define TIDLE 0x13
#define TINIL 0x14
#define TWUP 0x15
#define PARITY 0x16
#define BIT_SAMPLE_POINT 0x17 // OP2.0: Not yet supported
#define SYNC_JUMP_WIDTH 0x18 // OP2.0: Not yet supported
#define T1_MAX 0x1A
#define T2_MAX 0x1B
#define T3_MAX 0x24
#define T4_MAX 0x1C
#define T5_MAX 0x1D
#define ISO15765_BS 0x1E
#define ISO15765_STMIN 0x1F
#define DATA_BITS 0x20
#define FIVE_BAUD_MOD 0x21
#define BS_TX 0x22
#define STMIN_TX 0x23
#define ISO15765_WFT_MAX 0x25
// J2534-2
#define CAN_MIXED_FORMAT 0x8000
#define J1962_PINS 0x8001 // OP2.0: Not supported
#define SW_CAN_HS_DATA_RATE 0x8010 // OP2.0: Not supported
#define SW_CAN_SPEEDCHANGE_ENABLE 0x8011 // OP2.0: Not supported
#define SW_CAN_RES_SWITCH 0x8012 // OP2.0: Not supported
#define ACTIVE_CHANNELS 0x8020 // OP2.0: Not supported
#define SAMPLE_RATE 0x8021 // OP2.0: Not supported
#define SAMPLES_PER_READING 0x8022 // OP2.0: Not supported
#define READINGS_PER_MSG 0x8023 // OP2.0: Not supported
#define AVERAGING_METHOD 0x8024 // OP2.0: Not supported
#define SAMPLE_RESOLUTION 0x8025 // OP2.0: Not supported
#define INPUT_RANGE_LOW 0x8026 // OP2.0: Not supported
#define INPUT_RANGE_HIGH 0x8027 // OP2.0: Not supported
// Tactrix specific parameter IDs
#define TX_PARAM_BASE 0x9000
#define TX_PARAM_STOP_BITS (TX_PARAM_BASE_BASE+0)
//////////////////////
// PARITY definitions
//////////////////////
#define NO_PARITY 0
#define ODD_PARITY 1
#define EVEN_PARITY 2
////////////////////////////////
// CAN_MIXED_FORMAT definitions
////////////////////////////////
#define CAN_MIXED_FORMAT_OFF 0
#define CAN_MIXED_FORMAT_ON 1
#define CAN_MIXED_FORMAT_ALL_FRAMES 2
/////////////
// Error IDs
/////////////
// J2534-1
#define ERR_SUCCESS 0x00
#define STATUS_NOERROR 0x00
#define ERR_NOT_SUPPORTED 0x01
#define ERR_INVALID_CHANNEL_ID 0x02
#define ERR_INVALID_PROTOCOL_ID 0x03
#define ERR_NULL_PARAMETER 0x04
#define ERR_INVALID_IOCTL_VALUE 0x05
#define ERR_INVALID_FLAGS 0x06
#define ERR_FAILED 0x07
#define ERR_DEVICE_NOT_CONNECTED 0x08
#define ERR_TIMEOUT 0x09
#define ERR_INVALID_MSG 0x0A
#define ERR_INVALID_TIME_INTERVAL 0x0B
#define ERR_EXCEEDED_LIMIT 0x0C
#define ERR_INVALID_MSG_ID 0x0D
#define ERR_DEVICE_IN_USE 0x0E
#define ERR_INVALID_IOCTL_ID 0x0F
#define ERR_BUFFER_EMPTY 0x10
#define ERR_BUFFER_FULL 0x11
#define ERR_BUFFER_OVERFLOW 0x12
#define ERR_PIN_INVALID 0x13
#define ERR_CHANNEL_IN_USE 0x14
#define ERR_MSG_PROTOCOL_ID 0x15
#define ERR_INVALID_FILTER_ID 0x16
#define ERR_NO_FLOW_CONTROL 0x17
#define ERR_NOT_UNIQUE 0x18
#define ERR_INVALID_BAUDRATE 0x19
#define ERR_INVALID_DEVICE_ID 0x1A
// OP2.0 Tactrix specific
#define ERR_OEM_VOLTAGE_TOO_LOW 0x78 // OP2.0: the requested output voltage is lower than the OP2.0 capabilities
#define ERR_OEM_VOLTAGE_TOO_HIGH 0x77 // OP2.0: the requested output voltage is higher than the OP2.0 capabilities
/////////////////////////
// PassThruConnect flags
/////////////////////////
#define CAN_29BIT_ID 0x00000100
#define ISO9141_NO_CHECKSUM 0x00000200
#define CAN_ID_BOTH 0x00000800
#define ISO9141_K_LINE_ONLY 0x00001000
#define SNIFF_MODE 0x10000000 // OP2.0: listens to a bus (e.g. CAN) without acknowledging
//////////////////
// RxStatus flags
//////////////////
#define TX_MSG_TYPE 0x00000001
#define START_OF_MESSAGE 0x00000002
#define ISO15765_FIRST_FRAME 0x00000002
#define RX_BREAK 0x00000004
#define TX_DONE 0x00000008
#define ISO15765_PADDING_ERROR 0x00000010
#define ISO15765_EXT_ADDR 0x00000080
#define ISO15765_ADDR_TYPE 0x00000080
//#define CAN_29BIT_ID 0x00000100 // (already defined above)
//////////////////
// TxStatus flags
//////////////////
#define ISO15765_FRAME_PAD 0x00000040
//#define ISO15765_ADDR_TYPE 0x00000080 // (already defined above)
//#define CAN_29BIT_ID 0x00000100 // (already defined above)
#define WAIT_P3_MIN_ONLY 0x00000200
#define SW_CAN_HV_TX 0x00000400 // OP2.0: Not supported
#define SCI_MODE 0x00400000 // OP2.0: Not supported
#define SCI_TX_VOLTAGE 0x00800000 // OP2.0: Not supported
////////////////
// Filter types
////////////////
#define PASS_FILTER 0x00000001
#define BLOCK_FILTER 0x00000002
#define FLOW_CONTROL_FILTER 0x00000003
/////////////////
// Message struct
/////////////////
#define PASSTHRU_MSG_DATA_SIZE 4128
typedef struct
{
unsigned long ProtocolID;
unsigned long RxStatus;
unsigned long TxFlags;
unsigned long Timestamp;
unsigned long DataSize;
unsigned long ExtraDataIndex;
unsigned char Data[PASSTHRU_MSG_DATA_SIZE];
} PASSTHRU_MSG;
////////////////
// IOCTL structs
////////////////
typedef struct
{
unsigned long Parameter;
unsigned long Value;
} SCONFIG;
typedef struct
{
unsigned long NumOfParams;
SCONFIG *ConfigPtr;
} SCONFIG_LIST;
typedef struct
{
unsigned long NumOfBytes;
unsigned char *BytePtr;
} SBYTE_ARRAY;
#endif // J2534_TATRIX_LINUX_H