From d55feec17a4fae09c44fec714b9e2e84f56c7a87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Czeka=C5=84ski?= Date: Fri, 13 Sep 2024 18:22:34 +0200 Subject: [PATCH] VW MQB: Add CRC for Airbag_01, ESP_02, ESP10, ESP33, Licht_Anf_01 (#1016) VW MQB: Add crc for Airbag_01, ESP_02, ESP_10, ESP_33 and Licht_Anf_01 --- opendbc/can/common.cc | 5 ++ opendbc/can/tests/test_checksums.py | 80 +++++++++++++++++++++++++++++ opendbc/dbc/vw_mqb_2010.dbc | 47 ++++++++++++++--- 3 files changed, 125 insertions(+), 7 deletions(-) diff --git a/opendbc/can/common.cc b/opendbc/can/common.cc index ca5e7351e2..312abab530 100644 --- a/opendbc/can/common.cc +++ b/opendbc/can/common.cc @@ -115,11 +115,14 @@ struct CrcInitializer { static CrcInitializer crcInitializer; static const std::unordered_map> volkswagen_mqb_crc_constants { + {0x40, {0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40}}, // Airbag_01 {0x86, {0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86}}, // LWI_01 {0x9F, {0xF5, 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, 0xF5}}, // LH_EPS_03 {0xAD, {0x3F, 0x69, 0x39, 0xDC, 0x94, 0xF9, 0x14, 0x64, 0xD8, 0x6A, 0x34, 0xCE, 0xA2, 0x55, 0xB5, 0x2C}}, // Getriebe_11 {0xFD, {0xB4, 0xEF, 0xF8, 0x49, 0x1E, 0xE5, 0xC2, 0xC0, 0x97, 0x19, 0x3C, 0xC9, 0xF1, 0x98, 0xD6, 0x61}}, // ESP_21 + {0x101, {0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA}}, // ESP_02 {0x106, {0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07}}, // ESP_05 + {0x116, {0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC}}, // ESP_10 {0x117, {0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16}}, // ACC_10 {0x120, {0xC4, 0xE2, 0x4F, 0xE4, 0xF8, 0x2F, 0x56, 0x81, 0x9F, 0xE5, 0x83, 0x44, 0x05, 0x3F, 0x97, 0xDF}}, // TSK_06 {0x121, {0xE9, 0x65, 0xAE, 0x6B, 0x7B, 0x35, 0xE5, 0x5F, 0x4E, 0xC7, 0x86, 0xA2, 0xBB, 0xDD, 0xEB, 0xB4}}, // Motor_20 @@ -128,10 +131,12 @@ static const std::unordered_map> volkswagen_mq {0x12B, {0x6A, 0x38, 0xB4, 0x27, 0x22, 0xEF, 0xE1, 0xBB, 0xF8, 0x80, 0x84, 0x49, 0xC7, 0x9E, 0x1E, 0x2B}}, // GRA_ACC_01 {0x12E, {0xF8, 0xE5, 0x97, 0xC9, 0xD6, 0x07, 0x47, 0x21, 0x66, 0xDD, 0xCF, 0x6F, 0xA1, 0x94, 0x74, 0x63}}, // ACC_07 {0x187, {0x7F, 0xED, 0x17, 0xC2, 0x7C, 0xEB, 0x44, 0x21, 0x01, 0xFA, 0xDB, 0x15, 0x4A, 0x6B, 0x23, 0x05}}, // Motor_EV_01 + {0x1AB, {0x13, 0x21, 0x9B, 0x6A, 0x9A, 0x62, 0xD4, 0x65, 0x18, 0xF1, 0xAB, 0x16, 0x32, 0x89, 0xE7, 0x26}}, // ESP_33 {0x30C, {0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F}}, // ACC_02 {0x30F, {0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C}}, // SWA_01 {0x324, {0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27}}, // ACC_04 {0x3C0, {0xC3, 0xC3, 0xC3, 0xC3, 0xC3, 0xC3, 0xC3, 0xC3, 0xC3, 0xC3, 0xC3, 0xC3, 0xC3, 0xC3, 0xC3, 0xC3}}, // Klemmen_Status_01 + {0x3D5, {0xC5, 0x39, 0xC7, 0xF9, 0x92, 0xD8, 0x24, 0xCE, 0xF1, 0xB5, 0x7A, 0xC4, 0xBC, 0x60, 0xE3, 0xD1}}, // Licht_Anf_01 {0x65D, {0xAC, 0xB3, 0xAB, 0xEB, 0x7A, 0xE1, 0x3B, 0xF7, 0x73, 0xBA, 0x7C, 0x9E, 0x06, 0x5F, 0x02, 0xD9}}, // ESP_20 }; diff --git a/opendbc/can/tests/test_checksums.py b/opendbc/can/tests/test_checksums.py index 9ee6f04211..7166c8279b 100644 --- a/opendbc/can/tests/test_checksums.py +++ b/opendbc/can/tests/test_checksums.py @@ -95,6 +95,26 @@ def test_vw_mqb_crc_ACC_02(self, subtests): b'\xc0\xff\x3f\x00\x40\x30\x00\x40', ]) + def test_vw_mqb_crc_Airbag_01(self, subtests): + self.verify_vw_mqb_crc(subtests, "Airbag_01", 0x40, [ + b'\xaf\x00\x00\x80\xc0\x00\x20\x3e', + b'\x54\x01\x00\x80\xc0\x00\x20\x1a', + b'\x54\x02\x00\x80\xc0\x00\x60\x00', + b'\x31\x03\x00\x80\xc0\x00\x60\xf2', + b'\xe0\x04\x00\x80\xc0\x00\x60\xcc', + b'\xb3\x05\x00\x80\xc0\x00\x40\xde', + b'\xa4\x06\x00\x80\xc0\x00\x40\x18', + b'\x94\x07\x00\x80\xc0\x00\x20\x38', + b'\x2d\x08\x00\x80\xc0\x00\x60\xae', + b'\xc2\x09\x00\x80\xc0\x00\x00\x1c', + b'\x1f\x0a\x00\x80\xc0\x00\x60\x2c', + b'\x7f\x0b\x00\x80\xc0\x00\x00\x00', + b'\x03\x0c\x00\x80\xc0\x00\x40\xd6', + b'\x56\x0d\x00\x80\xc0\x00\x20\x50', + b'\x4a\x0e\x00\x80\xc0\x00\x20\xf2', + b'\xe5\x0f\x00\x80\xc0\x00\x40\xf6', + ]) + def test_vw_mqb_crc_LH_EPS_03(self, subtests): self.verify_vw_mqb_crc(subtests, "LH_EPS_03", 0x9F, [ b'\x11\x30\x2e\x00\x05\x1c\x80\x30', @@ -155,6 +175,26 @@ def test_vw_mqb_crc_ESP_21(self, subtests): b'\xfb\xdf\x1f\x80\x46\x00\x00\x00', ]) + def test_vw_mqb_crc_ESP_02(self, subtests): + self.verify_vw_mqb_crc(subtests, "ESP_02", 0x101, [ + b'\xf2\x00\x7e\xff\xa1\x2a\x40\x00', + b'\xd3\x01\x7d\x00\xa2\x0c\x02\x00', + b'\x03\x02\x7a\x06\xa2\x49\x42\x00', + b'\xfd\x03\x70\xfb\xa1\xde\x00\x00', + b'\x8e\x04\x7b\xf7\xa1\xd2\x01\x00', + b'\x0f\x05\x7d\xfd\xa1\x31\x40\x00', + b'\xb6\x06\x7d\x01\xa2\x0a\x40\x00', + b'\xe8\x07\x7e\xfd\xa1\x12\x40\x00', + b'\x74\x08\x7a\x01\xa2\x40\x01\x00', + b'\xe3\x09\x81\x00\xa2\xb5\x01\x00', + b'\xab\x0a\x74\x09\xa2\x9f\x42\x00', + b'\xf3\x0b\x80\x12\xa2\x94\x00\x00', + b'\x88\x0c\x7f\x07\xa2\x46\x00\x00', + b'\x6f\x0d\x7f\xff\xa1\x53\x40\x00', + b'\x38\x0e\x73\xd6\xa1\x6a\x40\x00', + b'\x49\x0f\x85\x12\xa2\xf6\x01\x00', + ]) + def test_vw_mqb_crc_ESP_05(self, subtests): self.verify_vw_mqb_crc(subtests, "ESP_05", 0x106, [ b'\x90\x80\x64\x00\x00\x00\xe7\x10', @@ -175,6 +215,26 @@ def test_vw_mqb_crc_ESP_05(self, subtests): b'\x3f\x8f\x82\x04\x00\x00\xe6\x30', ]) + def test_vw_mqb_crc_ESP_10(self, subtests): + self.verify_vw_mqb_crc(subtests, "ESP_10", 0x116, [ + b'\x2d\x00\xd5\x98\x9f\x26\x25\x0f', + b'\x24\x01\x60\x63\x2c\x5e\x3b\x0f', + b'\x08\x02\xb2\x2f\xee\x9a\x29\x0f', + b'\x7c\x03\x17\x07\x1d\xe5\x8c\x0f', + b'\xaa\x04\xd6\xe3\xeb\x98\xe8\x0f', + b'\x4e\x05\xbb\xd9\x65\x43\xca\x0f', + b'\x59\x06\x78\xbd\x25\xc6\xf2\xff', + b'\xaf\x07\x42\x85\x53\xbe\xbe\x0f', + b'\x2a\x08\xa6\xcd\x95\x8c\x12\x0f', + b'\xce\x09\x6e\x17\x6d\x1b\x2f\x0f', + b'\x60\x0a\xd3\xe6\x3a\x8d\xf0\x0f', + b'\xc5\x0b\xfc\x69\x57\x50\x21\x0f', + b'\x70\x0c\xde\xf3\x9d\xe9\x6b\xff', + b'\x62\x0d\xc4\x1a\xdb\x61\x7a\x0f', + b'\x76\x0e\x79\x69\xe3\x32\x67\x0f', + b'\x15\x0f\x51\x59\x56\x35\xb1\x0f', + ]) + def test_vw_mqb_crc_ACC_10(self, subtests): self.verify_vw_mqb_crc(subtests, "ACC_10", 0x117, [ b'\x9b\x00\x00\x40\x68\x00\x00\xff', @@ -395,6 +455,26 @@ def test_vw_mqb_crc_Klemmen_Status_01(self, subtests): b'\x35\x0f\x03\x00', ]) + def test_vw_mqb_crc_Licht_Anf_01(self, subtests): + self.verify_vw_mqb_crc(subtests, "Licht_Anf_01", 0x3D5, [ + b'\xc8\x00\x00\x04\x00\x00\x00\x00', + b'\x9f\x01\x00\x04\x00\x00\x00\x00', + b'\x5e\x02\x00\x04\x00\x00\x00\x00', + b'\x52\x03\x00\x04\x00\x00\x00\x00', + b'\xf2\x04\x00\x04\x00\x00\x00\x00', + b'\x79\x05\x00\x04\x00\x00\x00\x00', + b'\xe6\x06\x00\x04\x00\x00\x00\x00', + b'\xfd\x07\x00\x04\x00\x00\x00\x00', + b'\xf8\x08\x00\x04\x00\x00\x00\x00', + b'\xc6\x09\x00\x04\x00\x00\x00\x00', + b'\xf5\x0a\x00\x04\x00\x00\x00\x00', + b'\x1a\x0b\x00\x04\x00\x00\x00\x00', + b'\x65\x0c\x00\x04\x00\x00\x00\x00', + b'\x41\x0d\x00\x04\x00\x00\x00\x00', + b'\x7f\x0e\x00\x04\x00\x00\x00\x00', + b'\x98\x0f\x00\x04\x00\x00\x00\x00', + ]) + def test_vw_mqb_crc_ESP_20(self, subtests): self.verify_vw_mqb_crc(subtests, "ESP_20", 0x65D, [ b'\x98\x30\x2b\x10\x00\x00\x22\x81', diff --git a/opendbc/dbc/vw_mqb_2010.dbc b/opendbc/dbc/vw_mqb_2010.dbc index ecf529c5fa..6b01fd2140 100644 --- a/opendbc/dbc/vw_mqb_2010.dbc +++ b/opendbc/dbc/vw_mqb_2010.dbc @@ -102,8 +102,8 @@ BO_ 681 ACC_15: 8 XXX SG_ AWV_Warnlevel : 58|6@1+ (1,0) [0|63] "" XXX BO_ 64 Airbag_01: 8 Airbag_MQB - SG_ Airbag_01_CRC : 0|8@1+ (1,0) [0|255] "" BMS_MQB,Gateway_MQB,LEH_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB - SG_ Airbag_01_BZ : 8|4@1+ (1,0) [0|15] "" BMS_MQB,Gateway_MQB,LEH_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB + SG_ CHECKSUM : 0|8@1+ (1,0) [0|255] "" BMS_MQB,Gateway_MQB,LEH_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB + SG_ COUNTER : 8|4@1+ (1,0) [0|15] "" BMS_MQB,Gateway_MQB,LEH_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ AB_RGS_Anst : 12|4@1+ (1,0) [0|15] "" Gateway_MQB SG_ AB_Front_Crash : 16|1@1+ (1,0) [0|1] "" Gateway_MQB SG_ AB_Heck_Crash : 17|1@1+ (1,0) [0|1] "" Gateway_MQB @@ -126,6 +126,12 @@ BO_ 64 Airbag_01: 8 Airbag_MQB SG_ AB_MKB_gueltig : 39|1@1+ (1,0) [0|1] "" Gateway_MQB SG_ AB_MKB_Anforderung : 40|1@1+ (1,0) [0|1] "" Gateway_MQB SG_ AB_Versorgungsspannung : 41|1@1+ (1,0) [0|1] "" Gateway_MQB + SG_ AB_Deaktivierung_HV : 42|3@1+ (1.0,0.0) [0.0|7] "" BMS,Gateway_MQB,LEH_MQB,Motor_Hybrid_MQB + SG_ AB_EDR_Trigger : 45|2@1+ (1.0,0.0) [0.0|3] "" Gateway_MQB + SG_ AB_Gurtwarn_HFS : 47|1@1+ (1.0,0.0) [0.0|1] "" Gateway_MQB + SG_ AB_Gurtwarn_HBFS : 48|1@1+ (1.0,0.0) [0.0|1] "" Gateway_MQB + SG_ SC_Masterzeit_Offset : 53|2@1+ (5.08,0) [0.00|15.24] "Unit_Secon" Gateway_MQB + SG_ SC_Masterzeit : 57|7@1+ (0.04,0) [0.00|5.04] "Unit_Secon" Gateway_MQB BO_ 1312 Airbag_02: 8 Airbag_MQB SG_ AB_Belegung_VB : 26|2@1+ (1,0) [0|3] "" Gateway_MQB @@ -294,8 +300,8 @@ BO_ 260 EPB_01: 8 Gateway_MQB SG_ EPB_Status : 61|2@1+ (1,0) [0|3] "" Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB BO_ 257 ESP_02: 8 Gateway_MQB - SG_ ESP_02_CRC : 0|8@1+ (1,0) [0|255] "" Airbag_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB - SG_ ESP_02_BZ : 8|4@1+ (1,0) [0|15] "" Airbag_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB + SG_ CHECKSUM : 0|8@1+ (1,0) [0|255] "" Airbag_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB + SG_ COUNTER : 8|4@1+ (1,0) [0|15] "" Airbag_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ ESP_QBit_Gierrate : 12|1@1+ (1,0) [0|1] "" Airbag_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB SG_ ESP_QBit_Laengsbeschl : 13|1@1+ (1,0) [0|1] "" Airbag_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ ESP_QBit_Querb : 14|1@1+ (1,0) [0|1] "" Airbag_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB @@ -369,8 +375,8 @@ BO_ 914 ESP_07: 8 Gateway_MQB SG_ ESP_OBD_Status : 61|1@1+ (1,0) [0|1] "" Vector__XXX BO_ 278 ESP_10: 8 Gateway_MQB - SG_ ESP_10_CRC : 0|8@1+ (1,0) [0|255] "" Airbag_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB - SG_ ESP_10_BZ : 8|4@1+ (1,0) [0|15] "" Airbag_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB + SG_ CHECKSUM : 0|8@1+ (1,0) [0|255] "" Airbag_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB + SG_ COUNTER : 8|4@1+ (1,0) [0|15] "" Airbag_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ ESP_QBit_Wegimpuls_VL : 12|1@1+ (1,0) [0|1] "" Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ ESP_QBit_Wegimpuls_VR : 13|1@1+ (1,0) [0|1] "" Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ ESP_QBit_Wegimpuls_HL : 14|1@1+ (1,0) [0|1] "" Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB @@ -1449,7 +1455,34 @@ BO_ 988 Gateway_73: 8 XXX BO_ 792 Kamera_Status: 8 XXX -BO_ 981 Licht_Anf_01: 8 XXX +BO_ 981 Licht_Anf_01: 8 Vector__XXX + SG_ CHECKSUM : 0|8@1+ (1,0) [0|255] "" Vector__XXX + SG_ COUNTER : 8|4@1+ (1,0) [0|15] "" Vector__XXX + SG_ BCM1_Kurvenlicht_links_Anf : 12|1@1+ (1,0) [0|1] "" Vector__XXX + SG_ BCM1_Kurvenlicht_rechts_Anf : 13|1@1+ (1,0) [0|1] "" Vector__XXX + SG_ BCM1_Standlicht_Anf : 14|1@1+ (1,0) [0|1] "" Vector__XXX + SG_ BCM1_Abblendlicht_Anf : 15|1@1+ (1,0) [0|1] "" Vector__XXX + SG_ BCM1_Fernlicht_Anf : 16|1@1+ (1,0) [0|1] "" Vector__XXX + SG_ BCM1_Nebellicht_Anf : 17|1@1+ (1,0) [0|1] "" Vector__XXX + SG_ BCM1_Parklicht_li_Anf : 18|1@1+ (1,0) [0|1] "" Vector__XXX + SG_ BCM1_Parklicht_re_Anf : 19|1@1+ (1,0) [0|1] "" Vector__XXX + SG_ BCM1_Nebelschluss_Ahg_Anf : 20|1@1+ (1,0) [0|1] "" Vector__XXX + SG_ BCM1_Nebelschluss_Fzg_Anf : 21|1@1+ (1,0) [0|1] "" Vector__XXX + SG_ BCM1_Schlusslicht_Anf : 22|1@1+ (1,0) [0|1] "" Vector__XXX + SG_ BCM_Rueckfahrlicht_Anf : 23|1@1+ (1,0) [0|1] "" Vector__XXX + SG_ BCM1_Signaturlicht_Anf : 24|1@1+ (1,0) [0|1] "" Vector__XXX + SG_ BCM1_Umfeldleuchten_Anf : 25|1@1+ (1,0) [0|1] "" Vector__XXX + SG_ BCM1_Tagfahrlicht_Anf : 26|1@1+ (1,0) [0|1] "" Vector__XXX + SG_ BCM1_Regenlicht_Anf : 27|1@1+ (1,0) [0|1] "" Vector__XXX + SG_ BCM1_Autobahnlicht_Anf : 28|1@1+ (1,0) [0|1] "" Vector__XXX + SG_ BCM1_Touristen_Licht_Anf : 29|1@1+ (1,0) [0|1] "" Frontradar + SG_ BCM1_CH_aktiv : 30|1@1+ (1,0) [0|1] "" Vector__XXX + SG_ BCM1_LH_aktiv : 31|1@1+ (1,0) [0|1] "" Vector__XXX + SG_ BCM1_Gleitende_Leuchtw_Anf : 32|1@1+ (1,0) [0|1] "" Vector__XXX + SG_ BCM1_GLW_Fernlicht_Anf : 33|1@1+ (1,0) [0|1] "" Vector__XXX + SG_ BCM1_Adaptive_Lichtvert_Anf : 34|1@1+ (1,0) [0|1] "" Vector__XXX + SG_ BCM1_CH_LH_aktiv : 40|1@1+ (1,0) [0|1] "" Vector__XXX + SG_ BCM1_Allwetterlicht_Anf : 41|1@1+ (1,0) [0|1] "" Frontradar BO_ 1440 RLS_01: 8 XXX