| 1 | /* |
| 2 | * freediag - Vehicle Diagnostic Utility |
| 3 | * |
| 4 | * |
| 5 | * |
| 6 | * Copyright (C) 2001 Richard Almeida & Ibex Ltd ([email protected]) |
| 7 | * Copyright (C) 2015 fenugrec <[email protected]> |
| 8 | * Copyright (C) 2015-2016 Tomasz Kaźmierczak <[email protected]> |
| 9 | * |
| 10 | * This program is free software: you can redistribute it and/or modify |
| 11 | * it under the terms of the GNU General Public License as published by |
| 12 | * the Free Software Foundation, either version 3 of the License, or |
| 13 | * (at your option) any later version. |
| 14 | * |
| 15 | * This program is distributed in the hope that it will be useful, |
| 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 18 | * GNU General Public License for more details. |
| 19 | * |
| 20 | * You should have received a copy of the GNU General Public License |
| 21 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 22 | * |
| 23 | ************************************************************************* |
| 24 | * |
| 25 | * Diag |
| 26 | * |
| 27 | * L2 driver for Volkswagen Aktiengesellschaft (VAG) KW1281 protocol |
| 28 | * (Keyword 0x01 0x8a) |
| 29 | * |
| 30 | */ |
| 31 | #ifndef _DIAG_L2_VAG_H_ |
| 32 | #define _DIAG_L2_VAG_H_ |
| 33 | |
| 34 | #if defined(__cplusplus) |
| 35 | extern "C" { |
| 36 | #endif |
| 37 | |
| 38 | #define KWP1281_KW_BYTE_1 0x01 |
| 39 | #define KWP1281_KW_BYTE_2 0x8A |
| 40 | #define KWP1281_END_BYTE 0x03 |
| 41 | |
| 42 | //Initialization-specific times |
| 43 | #define KWP1281_T_R0 300 //before 5baud Initialization Byte (Scan Tool -> ECU) |
| 44 | #define KWP1281_T_R1_MIN 80 //between Init Byte and Synchronization Byte (ECU -> Scan Tool) |
| 45 | #define KWP1281_T_R1_MAX 210 |
| 46 | #define KWP1281_T_R2_MIN 5 //time between Sync Byte and KW1 Byte (ECU -> Scan Tool) |
| 47 | #define KWP1281_T_R2_MAX 50 // (KWP1281_T_R2_MAX is relaxed from standard) |
| 48 | #define KWP1281_T_R3_MIN 1 //time between KW1 and KW2 Byte (ECU -> Scan Tool) |
| 49 | #define KWP1281_T_R3_MAX 20 |
| 50 | #define KWP1281_T_R4_MIN 25 //time between KW2 Byte and KW2 Complement (Scan Tool -> ECU) |
| 51 | #define KWP1281_T_R4_MAX 50 |
| 52 | //After initialization |
| 53 | #define KWP1281_T_R5_MIN 25 //time between KW2 Complement and 1st ECU message (ECU -> Scan Tool) |
| 54 | #define KWP1281_T_R5_MAX 50 |
| 55 | #define KWP1281_T_RK 231 //time ECU waits before re-sending the Sync Byte if KW2 Complement was incorrect (ECU -> Scan Tool) |
| 56 | //Communication-specific times |
| 57 | #define KWP1281_T_R6_MIN 1 //time Scan Tool waits before sending next byte to ECU |
| 58 | #define KWP1281_T_R6_MAX 50 |
| 59 | #define KWP1281_T_R7_MIN 1 //time ECU waits before sending next byte to Scan Tool this is 0.5ms, actually... |
| 60 | #define KWP1281_T_R7_MAX 50 |
| 61 | #define KWP1281_T_R8 55 //timeout while waiting for a message byte (ECU and Scan Tool; R6_MAX+5 or R7_MAX+5) |
| 62 | #define KWP1281_T_RB_MIN 1 //time between messages (ECU and Scan Tool) |
| 63 | #define KWP1281_T_RB 1000 |
| 64 | #define KWP1281_T_RB_MAX 1100 |
| 65 | // |
| 66 | #define KWP1281_NA_RETRIES 5 //number of No Ack retries before a message is discarded |
| 67 | #define KWP1281_TO_RETRIES 3 //number of time-out retries before a message is discarded |
| 68 | |
| 69 | #define KWP1281_SID_ACK 0x09 |
| 70 | #define KWP1281_SID_NO_ACK 0x0A |
| 71 | |
| 72 | #if defined(__cplusplus) |
| 73 | } |
| 74 | #endif |
| 75 | #endif /* _DIAG_L2_VAG_H_ */ |
| 76 | |