maauto: survive inbound MessageError without closing
- Commit
c110343aedd1fdd0a26c34c032c1fa71c5f1b5c2- Author
- vayun-mathur <[email protected]>
- When
- 2026-09-12 14:39 UTC (2 months ago)
- Parents
3a65e9f
Diff
auto/protocol/src/main/java/com/vayunmathur/auto/protocol/GalControlSession.kt
diff --git a/auto/protocol/src/main/java/com/vayunmathur/auto/protocol/GalControlSession.kt b/auto/protocol/src/main/java/com/vayunmathur/auto/protocol/GalControlSession.ktindex 2424ddfa4f..7f657af610 100644--- a/auto/protocol/src/main/java/com/vayunmathur/auto/protocol/GalControlSession.kt+++ b/auto/protocol/src/main/java/com/vayunmathur/auto/protocol/GalControlSession.kt@@ -105,6 +105,15 @@ class GalControlSession( GalMessage.Control.PING_RESPONSE, -> emptyList() + // The head unit's rejection of one of our messages. Observed, not fatal:+ // gearhead's `izu` logs it (`ai(1698)`) and carries on, and channel-level+ // errors are per-channel (`iza` answers 0xff on the channel itself). The+ // transport stays alive -- pings keep flowing -- so the session must too.+ // The payload names the offending message; the trace in GalConnection+ // prints it. Killing the session here is what turned a recoverable+ // per-message rejection into a dead bring-up.+ GalMessage.Control.MESSAGE_ERROR -> emptyList()+ else -> fail("unexpected control message type 0x${type.toString(16)}") }
auto/protocol/src/test/java/com/vayunmathur/auto/protocol/GalControlSessionTest.kt
diff --git a/auto/protocol/src/test/java/com/vayunmathur/auto/protocol/GalControlSessionTest.kt b/auto/protocol/src/test/java/com/vayunmathur/auto/protocol/GalControlSessionTest.ktindex f8f22917ce..a3466d0651 100644--- a/auto/protocol/src/test/java/com/vayunmathur/auto/protocol/GalControlSessionTest.kt+++ b/auto/protocol/src/test/java/com/vayunmathur/auto/protocol/GalControlSessionTest.kt@@ -233,6 +233,22 @@ class GalControlSessionTest { assertNotNull(session.failure) } + @Test+ fun `a message error is observed, not fatal`() {+ // Live DHU behaviour: the head unit 0xff's a message it rejects while the+ // transport stays healthy (pings keep flowing). gearhead's `izu` logs it+ // and carries on; only framing errors tear down. The session must survive+ // so the bring-up can continue on the remaining channels.+ val session = session(GalCredential.serverEngine(context()))+ session.onMessage(GalMessage.Control.VERSION_REQUEST, versionRequest(1, 6))++ val replies = session.onMessage(GalMessage.Control.MESSAGE_ERROR, byteArrayOf())++ assertTrue(replies.isEmpty())+ assertEquals(SessionState.HANDSHAKING, session.state)+ assertNull(session.failure)+ }+ // ---- helpers ---- private fun versionRequest(major: Int, minor: Int): ByteArray =