diff --git a/opendbc_repo/opendbc/car/hyundai/carcontroller.py b/opendbc_repo/opendbc/car/hyundai/carcontroller.py index 10c9dbb80..6c11a60e1 100644 --- a/opendbc_repo/opendbc/car/hyundai/carcontroller.py +++ b/opendbc_repo/opendbc/car/hyundai/carcontroller.py @@ -241,7 +241,9 @@ class CarController(CarControllerBase): CS.blindspots_rear_corners, CS.blindspots_front_corner_1, CS.left_blindspot_from_radar, - CS.right_blindspot_from_radar)) + CS.right_blindspot_from_radar, + CC.leftBlinker, + CC.rightBlinker)) if self.frame % 2 == 0: can_sends.append(hyundaicanfd.create_acc_control(self.packer, self.CAN, CC.enabled, self.accel_last, accel, stopping, CC.cruiseControl.override, set_speed_in_units, hud_control)) diff --git a/opendbc_repo/opendbc/car/hyundai/carstate.py b/opendbc_repo/opendbc/car/hyundai/carstate.py index 717ea89c7..5f4ffde32 100644 --- a/opendbc_repo/opendbc/car/hyundai/carstate.py +++ b/opendbc_repo/opendbc/car/hyundai/carstate.py @@ -309,15 +309,13 @@ class CarState(CarStateBase): cp.vl["BLINDSPOTS_FRONT_CORNER_2"]["SIDE_DETECT_STATE"]) if self.CP.enableBsm: if self.CP.carFingerprint == CAR.HYUNDAI_IONIQ_6: - ret.leftBlindspot = (cp.vl["BLINDSPOTS_REAR_CORNERS"]["FL_INDICATOR"] != 0 or - cp.vl["BLINDSPOTS_REAR_CORNERS"]["FL_INDICATOR_ALT"] != 0 or + ret.leftBlindspot = (bool(cp.vl["BLINDSPOTS_REAR_CORNERS"]["BCW_LtIndSta"]) or self.left_blindspot_from_radar) - ret.rightBlindspot = (cp.vl["BLINDSPOTS_REAR_CORNERS"]["FR_INDICATOR"] != 0 or - cp.vl["BLINDSPOTS_REAR_CORNERS"]["FR_INDICATOR_ALT"] != 0 or + ret.rightBlindspot = (bool(cp.vl["BLINDSPOTS_REAR_CORNERS"]["BCW_RtIndSta"]) or self.right_blindspot_from_radar) else: - ret.leftBlindspot = cp.vl["BLINDSPOTS_REAR_CORNERS"]["FL_INDICATOR"] != 0 - ret.rightBlindspot = cp.vl["BLINDSPOTS_REAR_CORNERS"]["FR_INDICATOR"] != 0 + ret.leftBlindspot = bool(cp.vl["BLINDSPOTS_REAR_CORNERS"]["BCW_LtIndSta"]) + ret.rightBlindspot = bool(cp.vl["BLINDSPOTS_REAR_CORNERS"]["BCW_RtIndSta"]) if self.CP.carFingerprint == CAR.HYUNDAI_IONIQ_6: self.blindspots_rear_corners = copy.copy(cp.vl["BLINDSPOTS_REAR_CORNERS"]) diff --git a/opendbc_repo/opendbc/car/hyundai/hyundaicanfd.py b/opendbc_repo/opendbc/car/hyundai/hyundaicanfd.py index f2b03d48f..0d6df9420 100644 --- a/opendbc_repo/opendbc/car/hyundai/hyundaicanfd.py +++ b/opendbc_repo/opendbc/car/hyundai/hyundaicanfd.py @@ -202,16 +202,24 @@ def create_lfahda_cluster(packer, CAN, enabled, base_values=None): return packer.make_can_msg("LFAHDA_CLUSTER", CAN.ECAN, values) -def create_blindspot_status_messages(packer, CAN, rear_values, front_corner_values, left_blindspot=False, right_blindspot=False): +def create_blindspot_status_messages(packer, CAN, rear_values, front_corner_values, + left_blindspot=False, right_blindspot=False, + left_blinker=False, right_blinker=False): # Reuse the last known-good payload but regenerate the rolling counter/checksum. rear = {k: v for k, v in rear_values.items() if k not in ("CHECKSUM", "COUNTER")} front = {k: v for k, v in front_corner_values.items() if k not in ("CHECKSUM", "COUNTER")} - rear["LEFT_MB"] = int(left_blindspot) - rear["MORE_LEFT_PROB"] = int(right_blindspot) - rear["FL_INDICATOR"] = int(left_blindspot) - rear["FR_INDICATOR"] = int(right_blindspot) - rear["FL_INDICATOR_ALT"] = int(left_blindspot) - rear["FR_INDICATOR_ALT"] = int(right_blindspot) + left_state = 2 if left_blindspot and left_blinker else (1 if left_blindspot else 0) + right_state = 2 if right_blindspot and right_blinker else (1 if right_blindspot else 0) + + rear["BCW_Sta"] = int(left_blindspot or right_blindspot) + rear["BCW_LtIndSta"] = left_state + rear["BCW_RtIndSta"] = right_state + rear["BCW_IndSta"] = max(left_state, right_state) + rear["OSMrrLamp_LtIndSta"] = left_state + rear["OSMrrLamp_RtIndSta"] = right_state + # Keep the older fields aligned where they still correlate on some platforms. + rear["FL_INDICATOR"] = left_state + rear["FR_INDICATOR"] = right_state if "NEW_SIGNAL_3" not in front: front["NEW_SIGNAL_3"] = 1 diff --git a/opendbc_repo/opendbc/car/hyundai/tests/test_hyundai.py b/opendbc_repo/opendbc/car/hyundai/tests/test_hyundai.py index 1d961afa9..846cccd42 100644 --- a/opendbc_repo/opendbc/car/hyundai/tests/test_hyundai.py +++ b/opendbc_repo/opendbc/car/hyundai/tests/test_hyundai.py @@ -287,16 +287,30 @@ class TestHyundaiFingerprint: rear = { "CHECKSUM": 1111, "COUNTER": 77, - "LEFT_BLOCKED": 0, - "LEFT_MB": 0, - "MORE_LEFT_PROB": 0, + "BCW_Sta": 0, + "BCW_OnOffEquipSta": 0, + "BCW_LtIndSta": 0, + "BCW_RtIndSta": 0, + "BCW_LtSndWrngSta": 0, + "BCW_RtSndWrngSta": 0, "FL_INDICATOR": 0, "FR_INDICATOR": 0, - "RIGHT_BLOCKED": 0, - "COLLISION_AVOIDANCE_ACTIVE": 0, - "NEW_SIGNAL_2": 0, - "FL_INDICATOR_ALT": 0, - "FR_INDICATOR_ALT": 0, + "BCW_SnstvtyModRetVal": 0, + "BCW_IndSta": 0, + "BCA_OnOffEquip2Sta": 0, + "BCA_Sta": 0, + "BCA_OnOffEquipSta": 0, + "BCA_DRV_WarnSta": 0, + "BCA_Plus_Deccel_Req": 0, + "BCA_Plus_BrkCmdSta": 0, + "BCA_Plus_LtWrngSta": 0, + "BCA_Plus_RtWrngSta": 0, + "BCA_Plus_FuncStat": 0, + "BCA_Plus_Sta": 0, + "Brake_Control_RL": 0, + "Brake_Control_RR": 0, + "OSMrrLamp_LtIndSta": 0, + "OSMrrLamp_RtIndSta": 0, } front = { "CHECKSUM": 2222, @@ -312,20 +326,31 @@ class TestHyundaiFingerprint: "NEW_SIGNAL_1": 0, } - msgs = hyundaicanfd.create_blindspot_status_messages(packer, can_bus, rear, front, left_blindspot=True, right_blindspot=False) + msgs = hyundaicanfd.create_blindspot_status_messages(packer, can_bus, rear, front, + left_blindspot=True, right_blindspot=False, + left_blinker=False, right_blinker=False) parser.update([(1, msgs)]) assert parser.can_valid assert parser.vl["BLINDSPOTS_REAR_CORNERS"]["COUNTER"] == 0 assert parser.vl["BLINDSPOTS_FRONT_CORNER_1"]["COUNTER"] == 0 - assert parser.vl["BLINDSPOTS_REAR_CORNERS"]["LEFT_MB"] == 1 - assert parser.vl["BLINDSPOTS_REAR_CORNERS"]["MORE_LEFT_PROB"] == 0 + assert parser.vl["BLINDSPOTS_REAR_CORNERS"]["BCW_Sta"] == 1 + assert parser.vl["BLINDSPOTS_REAR_CORNERS"]["BCW_LtIndSta"] == 1 + assert parser.vl["BLINDSPOTS_REAR_CORNERS"]["BCW_RtIndSta"] == 0 + assert parser.vl["BLINDSPOTS_REAR_CORNERS"]["OSMrrLamp_LtIndSta"] == 1 + assert parser.vl["BLINDSPOTS_REAR_CORNERS"]["OSMrrLamp_RtIndSta"] == 0 assert parser.vl["BLINDSPOTS_REAR_CORNERS"]["FL_INDICATOR"] == 1 assert parser.vl["BLINDSPOTS_REAR_CORNERS"]["FR_INDICATOR"] == 0 - assert parser.vl["BLINDSPOTS_REAR_CORNERS"]["FL_INDICATOR_ALT"] == 1 - assert parser.vl["BLINDSPOTS_REAR_CORNERS"]["FR_INDICATOR_ALT"] == 0 assert parser.vl["BLINDSPOTS_FRONT_CORNER_1"]["NEW_SIGNAL_3"] == 1 + flash_msgs = hyundaicanfd.create_blindspot_status_messages(packer, can_bus, rear, front, + left_blindspot=True, right_blindspot=False, + left_blinker=True, right_blinker=False) + parser.update([(1, flash_msgs)]) + + assert parser.vl["BLINDSPOTS_REAR_CORNERS"]["BCW_LtIndSta"] == 2 + assert parser.vl["BLINDSPOTS_REAR_CORNERS"]["OSMrrLamp_LtIndSta"] == 2 + def test_ioniq_6_blindspot_radar_state_decode(self): assert decode_ioniq_6_blindspot_radar_state(0x02) == (False, False) assert decode_ioniq_6_blindspot_radar_state(0x0A) == (False, True) diff --git a/opendbc_repo/opendbc/dbc/generator/hyundai/hyundai_canfd.dbc b/opendbc_repo/opendbc/dbc/generator/hyundai/hyundai_canfd.dbc index 96040f2bf..c0b5517e7 100644 --- a/opendbc_repo/opendbc/dbc/generator/hyundai/hyundai_canfd.dbc +++ b/opendbc_repo/opendbc/dbc/generator/hyundai/hyundai_canfd.dbc @@ -393,16 +393,30 @@ BO_ 437 FR_CMR_03_50ms: 32 FR_CMR BO_ 442 BLINDSPOTS_REAR_CORNERS: 24 XXX SG_ CHECKSUM : 0|16@1+ (1,0) [0|65535] "" XXX SG_ COUNTER : 16|8@1+ (1,0) [0|255] "" XXX - SG_ LEFT_BLOCKED : 24|1@0+ (1,0) [0|1] "" XXX - SG_ LEFT_MB : 30|1@0+ (1,0) [0|3] "" XXX - SG_ MORE_LEFT_PROB : 32|1@1+ (1,0) [0|3] "" XXX + SG_ BCW_Sta : 24|1@0+ (1,0) [0|1] "" XXX + SG_ BCW_OnOffEquipSta : 28|2@1+ (1,0) [0|3] "" XXX + SG_ BCW_LtIndSta : 31|2@0+ (1,0) [0|3] "" XXX + SG_ BCW_RtIndSta : 32|2@1+ (1,0) [0|3] "" XXX + SG_ BCW_LtSndWrngSta : 34|2@1+ (1,0) [0|3] "" XXX + SG_ BCW_RtSndWrngSta : 36|10@1+ (1,0) [0|1023] "" XXX SG_ FL_INDICATOR : 46|6@0+ (1,0) [0|1] "" XXX - SG_ FR_INDICATOR : 54|6@0+ (1,0) [0|63] "" XXX - SG_ RIGHT_BLOCKED : 64|1@0+ (1,0) [0|1] "" XXX - SG_ COLLISION_AVOIDANCE_ACTIVE : 68|1@0+ (1,0) [0|1] "" XXX - SG_ NEW_SIGNAL_2 : 96|1@0+ (1,0) [0|1] "" XXX - SG_ FL_INDICATOR_ALT : 138|1@0+ (1,0) [0|1] "" XXX - SG_ FR_INDICATOR_ALT : 141|1@0+ (1,0) [0|1] "" XXX + SG_ FR_INDICATOR : 54|2@0+ (1,0) [0|3] "" XXX + SG_ BCW_SnstvtyModRetVal : 56|3@1+ (1,0) [0|7] "" XXX + SG_ BCW_IndSta : 59|3@1+ (1,0) [0|7] "" XXX + SG_ BCA_OnOffEquip2Sta : 62|2@1+ (1,0) [0|3] "" XXX + SG_ BCA_Sta : 64|1@0+ (1,0) [0|1] "" XXX + SG_ BCA_OnOffEquipSta : 68|1@0+ (1,0) [0|1] "" XXX + SG_ BCA_DRV_WarnSta : 76|4@1+ (1,0) [0|15] "" XXX + SG_ BCA_Plus_Deccel_Req : 80|4@1+ (1,0) [0|15] "" XXX + SG_ BCA_Plus_BrkCmdSta : 84|2@1+ (1,0) [0|3] "" XXX + SG_ BCA_Plus_LtWrngSta : 86|2@1+ (1,0) [0|3] "" XXX + SG_ BCA_Plus_RtWrngSta : 88|5@1+ (1,0) [0|31] "" XXX + SG_ BCA_Plus_FuncStat : 93|3@1+ (1,0) [0|7] "" XXX + SG_ BCA_Plus_Sta : 96|1@0+ (1,0) [0|1] "" XXX + SG_ Brake_Control_RL : 110|2@1+ (1,0) [0|3] "" XXX + SG_ Brake_Control_RR : 118|2@1+ (1,0) [0|3] "" XXX + SG_ OSMrrLamp_LtIndSta : 128|2@1+ (1,0) [0|3] "" XXX + SG_ OSMrrLamp_RtIndSta : 130|6@1+ (1,0) [0|63] "" XXX BO_ 463 CRUISE_BUTTONS: 8 XXX SG_ _CHECKSUM : 0|8@1+ (1,0) [0|65535] "" XXX diff --git a/opendbc_repo/opendbc/dbc/hyundai_canfd_generated.dbc b/opendbc_repo/opendbc/dbc/hyundai_canfd_generated.dbc index 8b09c9856..fb9b336c1 100644 --- a/opendbc_repo/opendbc/dbc/hyundai_canfd_generated.dbc +++ b/opendbc_repo/opendbc/dbc/hyundai_canfd_generated.dbc @@ -630,16 +630,30 @@ BO_ 437 FR_CMR_03_50ms: 32 FR_CMR BO_ 442 BLINDSPOTS_REAR_CORNERS: 24 XXX SG_ CHECKSUM : 0|16@1+ (1,0) [0|65535] "" XXX SG_ COUNTER : 16|8@1+ (1,0) [0|255] "" XXX - SG_ LEFT_BLOCKED : 24|1@0+ (1,0) [0|1] "" XXX - SG_ LEFT_MB : 30|1@0+ (1,0) [0|3] "" XXX - SG_ MORE_LEFT_PROB : 32|1@1+ (1,0) [0|3] "" XXX + SG_ BCW_Sta : 24|1@0+ (1,0) [0|1] "" XXX + SG_ BCW_OnOffEquipSta : 28|2@1+ (1,0) [0|3] "" XXX + SG_ BCW_LtIndSta : 31|2@0+ (1,0) [0|3] "" XXX + SG_ BCW_RtIndSta : 32|2@1+ (1,0) [0|3] "" XXX + SG_ BCW_LtSndWrngSta : 34|2@1+ (1,0) [0|3] "" XXX + SG_ BCW_RtSndWrngSta : 36|10@1+ (1,0) [0|1023] "" XXX SG_ FL_INDICATOR : 46|6@0+ (1,0) [0|1] "" XXX - SG_ FR_INDICATOR : 54|6@0+ (1,0) [0|63] "" XXX - SG_ RIGHT_BLOCKED : 64|1@0+ (1,0) [0|1] "" XXX - SG_ COLLISION_AVOIDANCE_ACTIVE : 68|1@0+ (1,0) [0|1] "" XXX - SG_ NEW_SIGNAL_2 : 96|1@0+ (1,0) [0|1] "" XXX - SG_ FL_INDICATOR_ALT : 138|1@0+ (1,0) [0|1] "" XXX - SG_ FR_INDICATOR_ALT : 141|1@0+ (1,0) [0|1] "" XXX + SG_ FR_INDICATOR : 54|2@0+ (1,0) [0|3] "" XXX + SG_ BCW_SnstvtyModRetVal : 56|3@1+ (1,0) [0|7] "" XXX + SG_ BCW_IndSta : 59|3@1+ (1,0) [0|7] "" XXX + SG_ BCA_OnOffEquip2Sta : 62|2@1+ (1,0) [0|3] "" XXX + SG_ BCA_Sta : 64|1@0+ (1,0) [0|1] "" XXX + SG_ BCA_OnOffEquipSta : 68|1@0+ (1,0) [0|1] "" XXX + SG_ BCA_DRV_WarnSta : 76|4@1+ (1,0) [0|15] "" XXX + SG_ BCA_Plus_Deccel_Req : 80|4@1+ (1,0) [0|15] "" XXX + SG_ BCA_Plus_BrkCmdSta : 84|2@1+ (1,0) [0|3] "" XXX + SG_ BCA_Plus_LtWrngSta : 86|2@1+ (1,0) [0|3] "" XXX + SG_ BCA_Plus_RtWrngSta : 88|5@1+ (1,0) [0|31] "" XXX + SG_ BCA_Plus_FuncStat : 93|3@1+ (1,0) [0|7] "" XXX + SG_ BCA_Plus_Sta : 96|1@0+ (1,0) [0|1] "" XXX + SG_ Brake_Control_RL : 110|2@1+ (1,0) [0|3] "" XXX + SG_ Brake_Control_RR : 118|2@1+ (1,0) [0|3] "" XXX + SG_ OSMrrLamp_LtIndSta : 128|2@1+ (1,0) [0|3] "" XXX + SG_ OSMrrLamp_RtIndSta : 130|6@1+ (1,0) [0|63] "" XXX BO_ 463 CRUISE_BUTTONS: 8 XXX SG_ _CHECKSUM : 0|8@1+ (1,0) [0|65535] "" XXX