基於CAN總線的KWP2000協議

結構如下:
              CAN Bus

KWP on CAN Identifier

Parameter Value [n] Description
Transmit ID 0x18DAFA00 ECU ->tester
Receive ID 0x18DA00FA Tester -> ECU

    KWP 2000 on CAN協議基於握手報文。對於來自測試人員的每個請求,ECU必須在新請求之前生成一個積極或消極的響應。

    Single Frame:如果要傳輸的數據數量小於7(標準添加)/ 6(擴展添加)數據字節,則使用單幀報文。第一個(標準尋址)/第二個(擴展尋址)字節是PCI字節。PCI字節的上4位包含0x0的代碼,而低四位表示:包括SID在內的參數的數量。

Bytes of the Single Frame message

Bytes 1 2 3 4 5 6 7 8
Normal addressing 0x0 len SID par par par par par par
Extended addressing ext. addr. 0x0 len SID par par par par par

                single message
               single transfer
                parameter
    第一幀的佈局與單幀的佈局相似。一個區別是額外的長度(len)字節已經添加(12位len允許最多傳輸4095字節的數據)。第一幀的代碼是0x1。
                first frame
    在PCI字節的下4字節中存儲了一個計數器(ctr)。計數器的初始值是0x01。它對每個連續的幀遞增。當到達0x0F的值時,計數器被重新設置爲0x00
                consecutive frame
    如果接收到類型爲0x01的流控制,即發送(CTS)消息,發送方可以繼續傳輸。如果類型是0x01(流控制等待),發送方必須重新啓動超時計時器。通過流控制等待消息,接收端可以延遲數據字節的進一步傳輸。參數BSmax定義了在發送方等待接收方生成的流控制消息之前,允許發送方發送的連續幀數。STmin定義了分離時間,即兩個連續幀之間的最小持續時間。發送方必須確保此分離時間不屬於STmin。
                control frame
                software operating states
驅動模式是控制單元接受汽車相關控制任務的正常運行狀態。

KWP services for flash programming in driving mode

Service name Service ID Usage
securityAccess 0x27 Security level for flash programming
startDiagnosticSession 0x10 Start flash programming mode
readECUIdentification 0x1A Read ECU identification

編程模式是實際的flash編程模式,支持flash編程所需的所有KWP服務
KWP services in the programming mode

Service name Service ID Usage
startCommunication 0x81 Start of KWP communication
stopCommunication 0x82 Stop of KWP communication
startDiagnosticSession 0x10 Start flash programming mode
securityAccess 0x27 Security access #1 and #2
accessTimingParameter 0x83 Get and set the timing
testerPresent 0x3E Keep communication alive
writeDataByLocalIdentifier 0x3B Writing entry in historical zone
readECUIdentification 0x1A Bootblock version, identifier block
startRoutineByLocalIdentifier 0x31 Start erasing flash
startRoutineByLocalIdentifier 0x31 Start checksum verification of flash
stopRoutineByLocalIdentifier 0x32 Stop checksum or erase routine
requestDownload 0x34 Request for download of code and data
transferData 0x36 Send to ECU code and data
requestTransferExit 0x37 End of data transfer for programming

    這種模式是一種臨時的運行狀態,軟件在RAM中運行,因爲flash剛剛被刪除,因此無法訪問flash。當刪除完成時,軟件會自動跳到引導塊模式。
KWP services in the “RAM” mode

Service name Service ID Usage
StartRoutineByLocalId 0x31 Start erase flash
TesterPresent 0x3E Keep communication alive
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章