App 2.31.1: log the cruise control while driving, with every assist value
The 2.27.3 log wrote a line only when the target speed changed, so the car showed one line at the start. Now a line is written on any change of a mode or the target and every 2 s while driving, with the raw driver-assistance properties (target speed, assist and speed-assist modes, the followed object) and the reason for any unread value. The last 600 lines are kept in an appended file; the Logs tab shows 150. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LhzAVaUyqcw5PkGjz4mWW6
This commit is contained in:
@@ -172,6 +172,9 @@ object ReadFailureLog {
|
||||
lastReason.put(key, reason) != reason
|
||||
}
|
||||
|
||||
/** Why [key] last failed, or null when it answered (or was never read). */
|
||||
fun reason(key: String): String? = synchronized(lock) { lastReason[key] }
|
||||
|
||||
/** A property that starts answering again must not silence its next failure. */
|
||||
fun clear(key: String) {
|
||||
synchronized(lock) { lastReason.remove(key) }
|
||||
|
||||
@@ -434,6 +434,53 @@ object EVHardware {
|
||||
*/
|
||||
private const val PROP_CRUISE_TARGET_SPEED = 0x2160A15B // vendor float
|
||||
|
||||
/**
|
||||
* The other driver-assistance properties of `CarAdvancedAssistedDrivingManager` that may
|
||||
* say what the adaptive cruise control is doing, read raw for the Logs tab while their
|
||||
* meaning is established on the car: the operation mode of traffic-jam / intelligent
|
||||
* cruise assist (`LANE_TJAICAOPMD`, by the manager 0 no request, 1 object following,
|
||||
* 2 lane centre, 3 combined), the speed assist (`SPEED_ASST_SYS`, `SPEED_ASST_MODE`, by the
|
||||
* manager 0 off, 2 manual limiter, 3 intelligent), the traffic-jam assist switch, and the
|
||||
* object the ACC follows (`ACC_OBJ_*`: existence probability, longitudinal distance and
|
||||
* relative speed).
|
||||
*/
|
||||
private val ACC_DEBUG_PROPS = listOf(
|
||||
AccDebugProp("cc", PROP_CRUISE_TARGET_SPEED, float = true),
|
||||
AccDebugProp("ica", 0x2140A12A, float = false), // AAD_LANE_TJAICAOPMD
|
||||
AccDebugProp("tja", 0x2140A107, float = false), // AAD_TRAFFIC_JAM_ASST_SYS
|
||||
AccDebugProp("sas", 0x2140A101, float = false), // AAD_SPEED_ASST_SYS
|
||||
AccDebugProp("sam", 0x2140A102, float = false), // AAD_SPEED_ASST_MODE
|
||||
AccDebugProp("obj", 0x2160A12F, float = true), // AAD_ACC_OBJ_EXIST_PRBLTY
|
||||
AccDebugProp("dist", 0x2160A12C, float = true), // AAD_ACC_OBJ_LONG_RLTV_DIST
|
||||
AccDebugProp("rel", 0x2160A12E, float = true), // AAD_ACC_OBJ_LONG_RLTV_SPD
|
||||
)
|
||||
|
||||
private class AccDebugProp(val name: String, val id: Int, val float: Boolean)
|
||||
|
||||
/** The cruise control target speed as the car reports it, unmapped; null when unread. */
|
||||
fun getCruiseTargetSpeedRaw(): Float? = supportedTelemetryRead {
|
||||
getFloatPropertyCPM(PROP_CRUISE_TARGET_SPEED, AREA_GLOBAL)?.takeIf { it.isFinite() }
|
||||
}
|
||||
|
||||
/**
|
||||
* The driver-assistance properties above, one raw reading each, for debugging the adaptive
|
||||
* cruise control on the car: name to value (floats to two decimals), or to "unread" with
|
||||
* the reason the car gave. Read only; about eight calls, so not on the main thread.
|
||||
*/
|
||||
fun readAccDebug(): List<Pair<String, String>> = ACC_DEBUG_PROPS.map { prop ->
|
||||
val value: Any? = supportedTelemetryRead {
|
||||
if (prop.float) getFloatPropertyCPM(prop.id, AREA_GLOBAL)?.takeIf { it.isFinite() }
|
||||
else readPropertyCPM(prop.id, AREA_GLOBAL, Int::class.javaObjectType) { sCpmGetIntMethod } as? Int
|
||||
}
|
||||
prop.name to when (value) {
|
||||
is Float -> String.format(java.util.Locale.US, "%.2f", value)
|
||||
null -> "unread" + (ReadFailureLog.reason(
|
||||
"0x${Integer.toHexString(prop.id)}@0x${Integer.toHexString(AREA_GLOBAL)}")
|
||||
?.let { " ($it)" } ?: "")
|
||||
else -> value.toString()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* `HVAC_AMBIENT_TEMPERATURE`, the one in-car candidate left on this firmware.
|
||||
*
|
||||
@@ -538,11 +585,6 @@ object EVHardware {
|
||||
* answers, and this is what is left on a unit where it does not.
|
||||
* See [PROP_BMS_CHRG_STS] for the values.
|
||||
*/
|
||||
/** The cruise control target speed as the car reports it, unmapped; null when unread. */
|
||||
fun getCruiseTargetSpeedRaw(): Float? = supportedTelemetryRead {
|
||||
getFloatPropertyCPM(PROP_CRUISE_TARGET_SPEED, AREA_GLOBAL)?.takeIf { it.isFinite() }
|
||||
}
|
||||
|
||||
fun getVendorChargeStatus(): Int? =
|
||||
getIntPropertyCPM(PROP_BMS_CHRG_STS, AREA_GLOBAL).takeIf { it >= 0 }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user