簡介
KWP2000(Keyword Protocol2000)是歐洲汽車領域廣泛使用的一種車載診斷協議標準,該協議實現了一套完整的車載診斷服務,並且滿足E-OBD(EuropeanOn BoardDiagnose)標準。KWP2000最初是基於K線的診斷協議,由於K線物理層和數據鏈路層在網絡管理和通訊速率上的侷限性,使得K線無法滿足日趨複雜的車載診斷網絡的需求。而CAN網絡(ControllerArea Network)由於其非破壞性的網絡仲裁機制、較高的通訊速率(可達1Mbps)和靈活可靠的通訊方式,在車載網絡領域廣受青睞,越來越多的汽車製造商把CAN總線應用於汽車控制、診斷和通訊。
項目特定的kw2000服務的子組件:
外部通信軟件由兩部分組成:
• Communication handler
• Command Interpreter
報文結構:
一個報文包含: 報文頭、數據域、校驗和
每個字節在該報文結構中包含:1 開始位、8 數據位(最低有效位開始)、1 停止位
(1)字節是可選的,取決於報文格式字節
(2)服務標識是數據域的一部分
Format byte - Fmt:包含2 bits地址信息和6 bits長度信息。
A1 | A0 | L5 | L4 | L3 | L2 | L1 | L0 |
---|
Target address byte - Tgt: 目的地址信息
Source address byte - Src:源(傳輸設備)地址信息,是一個物理地址,此字節是可選的(總是與目標地址字節一起使用),並且僅在多節點總線拓撲上是必需的。對於點到點的連接,可以省略它。
Target and Source address bytes
Byte | Tester -> ECU | ECU -> Tester |
---|---|---|
Target address | ECU address (0x10) | Tester address (0xXX) |
Source address | Tester address (0xXX) | ECU address (0x10) |
Length Byte - Len:如果頭字節(L0到L5)的長度設置爲零,則提供此字節。它允許單元傳輸數據域超過63字節的報文。低於63的可能被省略。
Data Bytes:數據域可能包含63字節或255字節的信息,取決於長度信息。第一個字節是服務標識,根據所選擇的服務,後邊可能緊跟着參數和數據。
Data byte information
Sld | Service Identification byte |
---|---|
Data | Data bytes max 254 |
Checksum: 校驗和。
服務概述
支持診斷模式
DM [Hex] | Diagnostic Mode (DM) | Security access required? | Security access Mode [hex] |
---|---|---|---|
81 | Default Mode | NO | |
82 | End Of Line Upload Mode | YES | 0x01 / 0x02 |
83 | End Of Line Download Mode | YES | 0x03 / 0x04 |
85 | ECU Programming Mode | YES | 0x07 / 0x08 |
86 | ECU Development Mode | YES | 0x09 / 0x0A |
87 | ECU Adjustment Mode | YES | 0x0B / 0x0C |
88 | EOL VehicleUpload Mode | YES | 0x11 / 0x12 |
89 | EOL VehicleDownload Mode | YES | 0x13 / 0x14 |
90 | EOL Vehicle Customer Service Upload Mode | YES | 0x15 / 0x16 |
91 | EOL Vehicle Customer Service Download Mode | YES | 0x17 / 0x18 |
92 | EOL End Customer Service Uoload Mode | YES | 0x19 / 0x1A |
93 | EOLEndCustomerServiceDownloadMode | YES | 0x1B / 0x1C |
部分服務列表
診斷服務名稱 | 請求碼(十六進制) | 診斷服務名稱 | 請求碼(十六進制) | 診斷服務名稱 | 請求碼(十六進制) |
---|---|---|---|---|---|
startCommunication | 81 | securityAccess | 27 | Read Status Of Diagnostic Trouble Codes | 17 |
stopCommunication | 82 | readEcuIdentification | 1A | Read Diagnostic Trouble Codes By Status | 18 |
accessTimingParamerters | 83 | ecuReset | 11 | clearDiagnosticInformation | 14 |
CommunicationControl | 28 | readDataByLocalIdentifier | 21 | readFreezeFrameData | 12 |
startDiagnosticSession | 10 | readMemoryByAddress | 23 | requestUpload (read Flash) | 35 |
Control Diagnostic Trouble Codes Setting | 85 | requestDownload (write Flash) | 34 | transferData | 36 |
requestTransferExit | 37 | writeMemoryByAddress | 3D | writeDataByLocalIdentifier | 3B |
KWP 請求報文
Data byte | Parameter name | Hex value | Mnemonic |
---|---|---|---|
#1 | Diagnostic service name | $xx | SID |
#2 | Request parameter #1 | $xx | PARAM1(參數1) |
#3 to #n | Other request parameters | $xx | PARAMn(參數2) |
KWP 積極響應(positive response)
Data byte | Parameter name | Hex value | Mnemonic |
---|---|---|---|
#1 | Diagnostic service name OK | SID + $40 | SID OK |
#2 | Response parameter #1 | $xx | RES1 |
#3 to #n | Other response parameters | $xx | RESn |
KWP 消極響應(negative response)
Data byte | Parameter name | Hex value | Mnemonic |
---|---|---|---|
#4 | Negative response | $7F | NR |
#5 | Code of service received by ECU | $xx | SID |
#6 | Negative response code | $xx | RC |
negative response code table
Hex | Definition of Response Code | Mnemonic |
---|---|---|
00 | reservedByDocument 此值不應用作響應代碼。 | RBD |
10 | generalReject 服務被拒絕,但是ECU沒有指定拒絕的原因 | GR |
11 | serviceNotSupported 不支持請求的服務 | SNS |
12 | subFunctionNotSupported-invalidFormat 請求報文的參數或格式不匹配,此響應代碼不影響通信計時! | SFNS-IF |
21 | busy-RepeatRequest 已接收請求,但未在最大響應時間內完成操作 | BRR |
22 | conditionsNotCorrectOrRequestSequenceError 未滿足先決條件,可能序列請求順序錯誤。 | CNCORSE |
23 | routineNotCompleteOrServiceInProcess 正在執行,還未完成 | RNCOSP |
31 | requestOutOfRange 發現越限的值 | ROOR |
33 | securityAccessDenied-securityAccessRequested 安全策略不滿足,訪問被拒絕 | SADSAR |
35 | invalidKey 密鑰不匹配 | IK |
36 | exceedNumberOfAttempts 客戶端試圖獲取比允許的更多的安全訪問次數,失敗。 | ENOF |
37 | requiredTimeDelayNotExpired 在服務器需要的時間超時後,發起請求。 | RTDNE |
40 | downloadNotAccepted 由於某些故障不能完成下載。 | DNA |
41 | improperDownloadType ECU不支持請求下載數據的類型 | IDT |
42 | canNotDownloadToSpecifiedAddress 不能識別可用的下載地址 | CNDTSA |
43 | canNotDownloadNumberOfBytesRequested 不能識別可用的下載字節數 | CNDNOBR |
50 | uploadNotAccepted 由於某些故障條件不能完成上傳 | UNA |
51 | improperUploadType不支持上傳類型 | IUT |
52 | canNotUploadFromSpecifiedAddress 不能識別可用的上傳地址 | CNUFSA |
53 | canNotUploadNumberOfBytesRequested 不能識別可用的上傳字節數 | CNUNOBR |
77 | blockTransferDataChecksumError 校驗和不一樣 | BTDCE |
80 | serviceNotSupportedInActiveDiagnosticMode 在當前活動的診斷模式中,服務器(ECU)不支持所請求的服務。 | SNSADM |
81-8F | reservedByDocument 此值不應用作響應代碼。 | RBD |
90-9F | vehicleManufacturerSpecific 這一範圍的值是預留給汽車製造商的特定用途。 | VMS |
FA | checksumError | an application-RAM or flash-EPROM checksum error. |
FB | ECUErasingFlash ECU當前正在擦除flash-EPROM。 | RC_ERASE |
FC | ECUProgrammingFlash ECU目前正在爲flash-EPROM編程。 | RC_PROG |
FD | erasingError 擦除flash-EPROM出錯。 | RC_ERER |
FE | programmingError flash-EPROM編程出錯。 | RC_PRERR |
FF | reservedByDocument 此值不應用作響應代碼。 | RBD |