mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-12-02 04:53:40 +08:00
Fill missed Kona steering slots with neutral output
This commit is contained in:
@@ -1359,6 +1359,22 @@ static bool hyundai_kona_camera_output(const CANPacket_t *msg, CANPacket_t *outp
|
||||
}
|
||||
}
|
||||
hyundai_kona_pending = false;
|
||||
if (!*replaced && authority && consecutive && hyundai_kona_slot_owned) {
|
||||
// Keep the camera's status and counter without repeating old host torque.
|
||||
CANPacket_t neutral = *msg;
|
||||
neutral.data[5] &= 0x01U;
|
||||
neutral.data[6] = (neutral.data[6] & 0xC0U) | 0x08U;
|
||||
const uint16_t checksum = hyundai_common_canfd_compute_checksum(&neutral) ^ 0x041DU;
|
||||
neutral.data[0] = (uint8_t)checksum;
|
||||
neutral.data[1] = (uint8_t)(checksum >> 8U);
|
||||
neutral.bus = 0U;
|
||||
hyundai_kona_emitting = true;
|
||||
*replaced = safety_tx_hook(&neutral);
|
||||
hyundai_kona_emitting = false;
|
||||
if (*replaced) {
|
||||
*output = neutral;
|
||||
}
|
||||
}
|
||||
if (!*replaced) {
|
||||
const bool camera_neutral = ((msg->data[6] & 0x3FU) == 0x08U) && ((msg->data[5] & 0xFEU) == 0U);
|
||||
blocked = (hyundai_kona_slot_owned && !camera_neutral) ||
|
||||
|
||||
@@ -113,3 +113,38 @@ class TestHyundaiKonaCcncHandoff(unittest.TestCase):
|
||||
self.safety.set_relay_malfunction(True)
|
||||
self.assertEqual(self.forward(following)[0], -1)
|
||||
self.assertFalse(self.safety.safety_stage_tx_hook(host))
|
||||
|
||||
def test_empty_owned_slot_uses_neutral_camera_status(self):
|
||||
if self.safety.set_safety_hooks(structs.CarParams.SafetyModel.allOutput, 0) != 0:
|
||||
self.skipTest('Kona factory handoff is DEBUG only')
|
||||
self.mode(0x1C0C)
|
||||
self.safety.set_timer(1_000_000)
|
||||
for status in self.safety.rx_status:
|
||||
status.msg_seen = True
|
||||
status.valid_checksum = True
|
||||
status.valid_quality_flag = True
|
||||
status.last_timestamp = 1_000_000
|
||||
self.assertEqual(self.forward(self.packet(2, '784d1400000108f0000a000000640000'))[:2], (0, False))
|
||||
self.safety.set_controls_allowed(True)
|
||||
self.safety.set_aol_test_heartbeat(True)
|
||||
self.safety.aol_set_host_request(3)
|
||||
host = self.packet(0, 'a009150280001800000a000000900000')
|
||||
host[0].data[2] = 20
|
||||
from opendbc.car.hyundai.hyundaicanfd import hkg_can_fd_checksum
|
||||
crc = hkg_can_fd_checksum(0x12A, None, bytearray(host[0].data[0:16]))
|
||||
host[0].data[0], host[0].data[1] = crc & 255, crc >> 8
|
||||
self.safety.set_timer(1_005_000)
|
||||
self.assertTrue(self.safety.safety_stage_tx_hook(host))
|
||||
self.safety.set_timer(1_010_000)
|
||||
self.assertEqual(self.forward(self.packet(2, '5ce51500000108f0000a000000640000'))[:2], (0, True))
|
||||
|
||||
self.safety.set_timer(1_019_900)
|
||||
camera = self.packet(2, '110d1600000108f0000a000000640000')
|
||||
bus, replaced, output = self.forward(camera)
|
||||
self.assertEqual((bus, replaced), (0, True))
|
||||
self.assertTrue(output[0].fd)
|
||||
self.assertEqual(output[0].data[2], 22)
|
||||
self.assertEqual(output[0].data[5] & 0xFE, 0)
|
||||
self.assertEqual(output[0].data[6] & 0x3F, 8)
|
||||
self.assertEqual(output[0].data[7], camera[0].data[7])
|
||||
self.assertEqual(self.forward(camera)[0], -1)
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1 +1 @@
|
||||
DEV-968161b3-Pf38f504f-DEBUG
|
||||
DEV-19d9f323-Pf38f504f-DEBUG
|
||||
Binary file not shown.
+1
-1
@@ -1 +1 @@
|
||||
{"protected_inventory_sha256": "4f231e5a0476cf7eeae651eca98b8d0b1c871e36feab3d5fea00831707b5ca8c", "schema_version": 1}
|
||||
{"protected_inventory_sha256": "c201320d8500070b856e2c05eb212f5feda30020bb44e71d8946c6c756ebc3bb", "schema_version": 1}
|
||||
|
||||
Reference in New Issue
Block a user