brendan-w / python-OBD

OBD-II serial module for reading engine data
GNU General Public License v2.0
1.02k stars 360 forks source link

Value Returned Only on First Request - Then All Requests Lead to None. #268

Open mrbean26 opened 6 months ago

mrbean26 commented 6 months ago

Title describes the issue. Interestingly, the OBD&ELM connections read false even before the first query, however CAR connection reads true. here is the code I am using. `
import obd import time

obd.logger.setLevel(obd.logging.DEBUG)
print("1")
ports=obd.scan_serial()
print(ports)
connection=obd.OBD(ports[1], fast=False)
print("2")

while True:
        print("Car connected", connection.status()==obd.OBDStatus.CAR_CONNECTED)

        newCommand=obd.commands.RPM
        newQuery = connection.query(newCommand)
        print(newQuery.value)

        time.sleep(1.5)

`

and here is the debug log

============================================================= RESTART: C:\Users\Diag\Desktop\newscript.py ============================================================= 1 ['\\.\\COM3', '\\.\\COM4'] [obd.obd] ======================= python-OBD (v0.7.1) ======================= [obd.obd] Explicit port defined [obd.elm327] Initializing ELM327: PORT=\.\COM4 BAUD=auto PROTOCOL=auto [obd.elm327] Response from baud 38400: b'?\r\r>' [obd.elm327] Choosing baud 38400 [obd.elm327] write: b'ATZ\r' [obd.elm327] wait: 1 seconds [obd.elm327] read: b'\xfc\r\rELM327 v1.5\r\r>' [obd.elm327] write: b'ATE0\r' [obd.elm327] wait: 0 seconds [obd.elm327] read: b'ATE0\rOK\r\r>' [obd.elm327] write: b'ATH1\r' [obd.elm327] wait: 1 seconds [obd.elm327] read: b'OK\r\r>' [obd.elm327] write: b'ATL0\r' [obd.elm327] wait: 0 seconds [obd.elm327] read: b'OK\r\r>' [obd.elm327] write: b'AT RV\r' [obd.elm327] wait: 0 seconds [obd.elm327] read: b'14.3V\r\r>' [obd.elm327] write: b'ATSP0\r' [obd.elm327] wait: 0 seconds [obd.elm327] read: b'OK\r\r>' [obd.elm327] write: b'0100\r' [obd.elm327] wait: 0 seconds [obd.elm327] read: b'SEARCHING...\r48 6B 10 41 00 BE 3E B8 11 C9 \r\r>' [obd.elm327] write: b'ATDPN\r' [obd.elm327] wait: 0 seconds [obd.elm327] read: b'A3\r\r>' [obd.protocols.protocol] map ECU 16 --> ENGINE [obd.elm327] Connected Successfully: PORT=\.\COM4 BAUD=38400 PROTOCOL=3 [obd.obd] querying for supported commands [obd.obd] Sending command: b'0100': Supported PIDs [01-20] [obd.elm327] write: b'0100\r' [obd.elm327] wait: 0 seconds [obd.elm327] read: b'48 6B 10 41 00 BE 3E B8 11 C9 \r\r>' [obd.obd] Sending command: b'0120': Supported PIDs [21-40] [obd.elm327] write: b'0120\r' [obd.elm327] wait: 0 seconds [obd.elm327] read: b'48 6B 10 41 20 80 00 00 00 A4 \r\r>' [obd.obd] finished querying with 43 commands supported [obd.obd] =================================================================== 2 [obd.obd] Sending command: b'010C': Engine RPM [obd.elm327] write: b'010C\r' [obd.elm327] wait: 0 seconds [obd.elm327] read: b'48 6B 10 41 0C 0B 74 8F \r\r>' 733.0 revolutions_per_minute [obd.obd] Sending command: b'010C': Engine RPM [obd.elm327] write: b'010C\r' [obd.elm327] wait: 0 seconds [obd.elm327] read: b'NO DATA\r\r>' [obd.OBDCommand] b'010C': Engine RPM did not receive any acceptable messages None