mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-12-02 05:43:40 +08:00
Restore Kona steering requests on the Panda host transport
This commit is contained in:
@@ -1251,7 +1251,7 @@ static bool hyundai_kona_host_steering(void) {
|
||||
}
|
||||
|
||||
static bool hyundai_kona_lfa_valid(const CANPacket_t *msg) {
|
||||
return msg->fd && !msg->extended && (GET_LEN(msg) == 16U) &&
|
||||
return !msg->extended && (GET_LEN(msg) == 16U) &&
|
||||
(hyundai_canfd_get_checksum(msg) == (hyundai_common_canfd_compute_checksum(msg) ^ 0x041DU));
|
||||
}
|
||||
|
||||
@@ -1277,7 +1277,7 @@ static bool hyundai_kona_camera_without_slot(const CANPacket_t *msg) {
|
||||
static bool hyundai_kona_camera_release_current(const CANPacket_t *msg, uint32_t now) {
|
||||
return (msg->bus == 2U) && hyundai_kona_output_seen && hyundai_kona_host_output &&
|
||||
hyundai_kona_camera_seen && !relay_malfunction && !safety_rx_checks_invalid && aol_rx_healthy() &&
|
||||
!hyundai_kona_host_steering() && hyundai_kona_lfa_valid(msg) &&
|
||||
!hyundai_kona_host_steering() && msg->fd && hyundai_kona_lfa_valid(msg) &&
|
||||
((uint8_t)(msg->data[2] - hyundai_kona_output_counter) == 1U) &&
|
||||
((uint8_t)(msg->data[2] - hyundai_kona_camera_counter) == 1U) &&
|
||||
(safety_get_ts_elapsed(now, hyundai_kona_camera_ts) <= 20000U);
|
||||
@@ -1311,7 +1311,7 @@ static bool hyundai_kona_camera_output(const CANPacket_t *msg, CANPacket_t *outp
|
||||
const uint8_t delta = (uint8_t)(counter - hyundai_kona_camera_counter);
|
||||
const bool advancing = (delta > 0U) && (delta <= 127U);
|
||||
const bool consecutive = hyundai_kona_camera_seen && (delta == 1U) && (camera_age <= 20000U);
|
||||
blocked = !hyundai_kona_lfa_valid(msg) || safety_rx_checks_invalid || !aol_rx_healthy() ||
|
||||
blocked = !msg->fd || !hyundai_kona_lfa_valid(msg) || safety_rx_checks_invalid || !aol_rx_healthy() ||
|
||||
(hyundai_kona_camera_seen && (camera_age <= 50000U) && !advancing);
|
||||
if (!blocked) {
|
||||
hyundai_kona_camera_counter = counter;
|
||||
@@ -1344,6 +1344,7 @@ static bool hyundai_kona_camera_output(const CANPacket_t *msg, CANPacket_t *outp
|
||||
candidate.data[5] = (candidate.data[5] & 0x01U) | (uint8_t)((raw & 0x7FU) << 1U);
|
||||
candidate.data[6] = (candidate.data[6] & 0xF0U) | (uint8_t)(raw >> 7U);
|
||||
}
|
||||
candidate.fd = msg->fd;
|
||||
candidate.data[2] = counter;
|
||||
const uint16_t checksum = hyundai_common_canfd_compute_checksum(&candidate) ^ 0x041DU;
|
||||
candidate.data[0] = (uint8_t)checksum;
|
||||
@@ -1461,7 +1462,7 @@ static bool hyundai_canfd_tx_hook(const CANPacket_t *msg) {
|
||||
if (hyundai_kona_idle_handoff && (msg->addr == 0x12AU)) {
|
||||
const uint32_t now = microsecond_timer_get();
|
||||
allowed = hyundai_kona_emitting && !safety_rx_checks_invalid && aol_rx_healthy() && hyundai_kona_host_steering() &&
|
||||
hyundai_kona_lfa_valid(msg) && hyundai_kona_camera_seen &&
|
||||
msg->fd && hyundai_kona_lfa_valid(msg) && hyundai_kona_camera_seen &&
|
||||
(safety_get_ts_elapsed(now, hyundai_kona_camera_ts) <= 50000U) &&
|
||||
(msg->data[2] == hyundai_kona_camera_counter) && hyundai_kona_output_ready(now, true, msg->data[2]);
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ class TestHyundaiKonaCcncHandoff(unittest.TestCase):
|
||||
|
||||
def packet(self, bus, body):
|
||||
packet = libsafety_py.make_CANPacket(0x12A, bus, bytes.fromhex(body))
|
||||
packet[0].fd = 1
|
||||
packet[0].fd = bus == 2
|
||||
return packet
|
||||
|
||||
def test_handoff_is_debug_only_and_requires_exact_alternative_experience(self):
|
||||
@@ -71,6 +71,9 @@ class TestHyundaiKonaCcncHandoff(unittest.TestCase):
|
||||
status.valid_quality_flag = True
|
||||
status.last_timestamp = 1_000_000
|
||||
|
||||
camera[0].fd = 0
|
||||
self.assertEqual(self.forward(camera)[0], -1)
|
||||
camera[0].fd = 1
|
||||
self.assertEqual(self.forward(camera)[:2], (0, False))
|
||||
self.assertEqual(self.forward(camera)[0], -1)
|
||||
corrupt = self.packet(2, 'a6770a1881001800000a000000900000')
|
||||
@@ -88,11 +91,15 @@ class TestHyundaiKonaCcncHandoff(unittest.TestCase):
|
||||
host[0].data[0], host[0].data[1] = crc & 255, crc >> 8
|
||||
self.safety.set_timer(1_005_000)
|
||||
self.assertFalse(self.safety.safety_tx_hook(host))
|
||||
host[0].data[0] ^= 1
|
||||
self.assertFalse(self.safety.safety_stage_tx_hook(host))
|
||||
host[0].data[0] ^= 1
|
||||
self.assertTrue(self.safety.safety_stage_tx_hook(host))
|
||||
self.safety.set_timer(1_010_000)
|
||||
match = self.packet(2, '5ce51500000108f0000a000000640000')
|
||||
bus, replaced, output = self.forward(match)
|
||||
self.assertEqual((bus, replaced, output[0].data[2]), (0, True, 21))
|
||||
self.assertTrue(output[0].fd)
|
||||
self.assertEqual(output[0].data[7] & 0xF0, 0xF0)
|
||||
|
||||
self.safety.set_controls_allowed(False)
|
||||
|
||||
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-b666318e-Pf38f504f-DEBUG
|
||||
DEV-c4817d9a-Pf38f504f-DEBUG
|
||||
Binary file not shown.
+1
-1
@@ -1 +1 @@
|
||||
{"protected_inventory_sha256": "d7e4040d0eea396aa644f3e18da68be560b309575c874fe298173e9cc8f58fd3", "schema_version": 1}
|
||||
{"protected_inventory_sha256": "c305449b5668a10ceaac348e5d80ff657f5ab4daa9567e57b7bfaaeb88f0704a", "schema_version": 1}
|
||||
|
||||
Reference in New Issue
Block a user