fix: add OBD_SKIP_VOLTAGE_CHECK support for clone ELM327 adapters
Counterfeit ELM327 chips (common in cheap PL2303 USB adapters) often report bad/zero voltage even when the OBD connection is working. python-obd's check_voltage=True default rejects these. Add OBD_SKIP_VOLTAGE_CHECK=1 env var to pass check_voltage=False to obd.OBD(), documented in yaris-obd.service. Also document Phase 24.6 Yaris 2013 compatibility analysis in PLAN.md. Co-authored-by: Copilot <[email protected]>
This commit is contained in:
+6
-1
@@ -186,15 +186,20 @@ def connect_obd():
|
||||
return None
|
||||
|
||||
protocol = os.environ.get("OBD_PROTOCOL") or None
|
||||
# Some counterfeit ELM327 chips report bad/zero voltage even when the
|
||||
# connection is working; set OBD_SKIP_VOLTAGE_CHECK=1 if the adapter
|
||||
# fails to connect and logs a voltage-related error.
|
||||
check_voltage = os.environ.get("OBD_SKIP_VOLTAGE_CHECK") != "1"
|
||||
selected_port = port or detected_ports[0]
|
||||
print(
|
||||
f"{obd_status[2]} to {selected_port}"
|
||||
+ (f" using protocol {protocol}" if protocol else " using auto protocol")
|
||||
+ ("" if check_voltage else " (voltage check disabled)")
|
||||
+ "..."
|
||||
)
|
||||
|
||||
try:
|
||||
candidate = obd.OBD(portstr=selected_port, protocol=protocol)
|
||||
candidate = obd.OBD(portstr=selected_port, protocol=protocol, check_voltage=check_voltage)
|
||||
except Exception as error:
|
||||
print(
|
||||
f"OBD adapter detected at {selected_port}, but the ELM327 "
|
||||
|
||||
Reference in New Issue
Block a user