Discover Honda Fit firmware on normal CAN bus

This commit is contained in:
firestar5683
2026-11-22 11:48:58 -06:00
parent 31f8918db7
commit cd65e68b60
4 changed files with 25 additions and 10 deletions
+13 -4
View File
@@ -15,7 +15,7 @@ from opendbc.car.ford.discovery import (normal_bus0_selection as ford_normal_bus
normal_bus0_queries as ford_normal_bus0_queries, normal_bus_query_brand)
from opendbc.car.volvo.discovery import normal_bus_topology as volvo_normal_bus_topology
from opendbc.car.hyundai.discovery import normal_bus_topology
from opendbc.car.honda.discovery import normal_bus_topology as honda_normal_bus_topology
from opendbc.car.honda.discovery import NIDEC_BUS0_LAYOUT, normal_bus_topology as honda_normal_bus_topology
from opendbc.car.chrysler.discovery import normal_bus_topology as chrysler_normal_bus_topology
from opendbc.car.tesla.discovery import normal_bus0_topology as tesla_normal_bus0_topology
from opendbc.car.values import BRANDS
@@ -143,6 +143,7 @@ def fingerprint(can_recv: CanRecvCallable, can_send: CanSendCallable, set_obd_mu
cached = True
else:
carlog.warning("Getting VIN & FW versions")
full_scan = False
if known_gm_bus0:
# An explicit registered GM selection already identifies the query family.
# Current GM requests use normal bus 0. Keep live VIN/FW collection and
@@ -182,18 +183,26 @@ def fingerprint(can_recv: CanRecvCallable, can_send: CanSendCallable, set_obd_mu
volvo_probe=volvo_normal_bus_topology if not fw_versions.FW_QUERY_CONFIGS['volvo'].requests else None,
tesla_probe=tesla_normal_bus0_topology if _tesla_fw_uses_normal_bus0() else None) or
('honda' if honda_normal_bus_topology(normal_bus_packets) else None) or
('honda_nidec' if honda_normal_bus_topology(normal_bus_packets, layout=NIDEC_BUS0_LAYOUT) else None) or
('chrysler' if chrysler_normal_bus_topology(normal_bus_packets) else None)) is not None:
set_obd_multiplexing(False)
warmup_remaining = 0.1 - (time.monotonic() - start_time)
if warmup_remaining > 0:
time.sleep(warmup_remaining)
vin_buses = (0,) if normal_brand in ('ford', 'gm', 'volvo', 'tesla', 'chrysler') else (0, 1)
vin_buses = (0,) if normal_brand in ('ford', 'gm', 'volvo', 'tesla', 'chrysler', 'honda_nidec') else (0, 1)
vin_rx_addr, vin_rx_bus, vin = get_vin(can_recv, can_send, vin_buses)
car_fw = get_fw_versions(can_recv, can_send, set_obd_multiplexing,
query_brand=normal_brand, normal_bus_only=True)
if normal_brand == 'honda_nidec':
car_fw = get_fw_versions(can_recv, can_send, set_obd_multiplexing, query_brand='honda', query_bus=0)
exact, matches = match_fw_to_car(car_fw, vin)
full_scan = not (exact and matches == {'HONDA_FIT'})
else:
car_fw = get_fw_versions(can_recv, can_send, set_obd_multiplexing,
query_brand=normal_brand, normal_bus_only=True)
ecu_rx_addrs = {(fw.responseAddress, fw.subAddress or None, fw.bus) for fw in car_fw if fw.responseAddress > 0}
else:
full_scan = True
if full_scan:
# enable OBD multiplexing for VIN query
# NOTE: this takes ~0.1s and is relied on to allow sendcan subscriber to connect in time
set_obd_multiplexing(True)
+2 -1
View File
@@ -275,7 +275,7 @@ def get_fw_versions_ordered(can_recv: CanRecvCallable, can_send: CanSendCallable
def get_fw_versions(can_recv: CanRecvCallable, can_send: CanSendCallable, set_obd_multiplexing: ObdCallback, query_brand: str | None = None,
extra: OfflineFwVersions | None = None, timeout: float = 0.1, progress: bool = False,
*, normal_bus_only: bool = False) -> list[CarParams.CarFw]:
*, normal_bus_only: bool = False, query_bus: int | None = None) -> list[CarParams.CarFw]:
versions = VERSIONS.copy()
if query_brand is not None:
@@ -309,6 +309,7 @@ def get_fw_versions(can_recv: CanRecvCallable, can_send: CanSendCallable, set_ob
# Get versions and build capnp list to put into CarParams
car_fw = []
requests = [(brand, config, r) for brand, config, r in REQUESTS if is_brand(brand, query_brand) and
(query_bus is None or r.bus == query_bus) and
not (normal_bus_only and r.bus % 4 == 1 and r.obd_multiplexing)]
for addr_group in tqdm(addrs, disable=not progress): # split by subaddr, if any
for addr_chunk in chunks(addr_group):
+9 -4
View File
@@ -7,14 +7,19 @@ NORMAL_BUS_LAYOUT = {(1, 0x158): 8, (1, 0x17C): 8, (1, 0x18F): 7,
(1, 0x296): 4, (2, 0xE4): 5, (2, 0x400): 4}
def normal_bus_topology(packets):
# Nidec PT and alternate SCM button messages on normal bus 0.
NIDEC_BUS0_LAYOUT = {(0, 0x158): 8, (0, 0x17C): 8, (0, 0x18F): 7,
(0, 0x1A6): 8, (0, 0x156): 6}
def normal_bus_topology(packets, *, layout=NORMAL_BUS_LAYOUT):
observed = set()
for packet in packets:
for frame in packet:
key = (frame.src, frame.address)
if key in NORMAL_BUS_LAYOUT:
if (len(frame.dat) != NORMAL_BUS_LAYOUT[key] or
if key in layout:
if (len(frame.dat) != layout[key] or
honda_checksum(frame.address, None, frame.dat) != frame.dat[-1] & 0xF):
return False
observed.add(key)
return observed == NORMAL_BUS_LAYOUT.keys()
return observed == layout.keys()
+1 -1
View File
@@ -1 +1 @@
{"protected_inventory_sha256": "926dd708a28cc952cd2ca50b895e84251f18b23a2090263b5d0b423e7e94faed", "schema_version": 1}
{"protected_inventory_sha256": "671ffaaf12d603723936e73999fcef74a42665f248947b90bf9696ccd4e9d2df", "schema_version": 1}