Add protocol and supported command count

This commit is contained in:
2026-06-05 13:26:17 -06:00
parent ab77663d13
commit 0065ea8071

22
menu.py
View File

@@ -1,6 +1,7 @@
import logging import logging
import csv import csv
import time import time
import os
import obd import obd
from datetime import datetime from datetime import datetime
@@ -47,16 +48,15 @@ def read_codes(connection):
def live_data(connection): def live_data(connection):
if connection is None or not connection.is_connected():
print("\nLive Data") print("\nLive Data")
print("---------") print("---------")
if connection is None or not connection.is_connected():
print("Not connected to vehicle") print("Not connected to vehicle")
pause() pause()
return return
print("Live data running.") print("Live data running.")
print("Press Ctrl+C to stop and return to menu.\n") print("Press Ctrl+C to stop and return to menu.")
try: try:
while True: while True:
@@ -64,25 +64,29 @@ def live_data(connection):
speed = connection.query(obd.commands.SPEED) speed = connection.query(obd.commands.SPEED)
coolant = connection.query(obd.commands.COOLANT_TEMP) coolant = connection.query(obd.commands.COOLANT_TEMP)
print("\nLive Data") os.system("clear")
print("Live Data")
print("---------") print("---------")
print("Press Ctrl+C to stop")
print()
if rpm.is_null(): if rpm.is_null():
print("RPM: Not supported") print("RPM: Not supported")
else: else:
print("RPM:", rpm.value) print("RPM:", round(rpm.value.magnitude))
if speed.is_null(): if speed.is_null():
print("Speed: Not supported") print("Speed: Not supported")
else: else:
speed_mph = speed.value.to("mile_per_hour") speed_mph = speed.value.to("mile_per_hour")
print("Speed:", speed_mph) print("Speed:", round(speed_mph.magnitude), "mph")
if coolant.is_null(): if coolant.is_null():
print("Coolant Temp: Not supported") print("Coolant Temp: Not supported")
else: else:
coolant_f = coolant.value.to("degF") coolant_f = coolant.value.to("degF")
print("Coolant Temp:", coolant_f) print("Coolant Temp:", round(coolant_f.magnitude), "°F")
time.sleep(1) time.sleep(1)
@@ -110,6 +114,10 @@ def vehicle_info(connection):
else: else:
print("VIN: Not available") print("VIN: Not available")
print()
print("Protocol:", connection.protocol_name())
print("Supported Commands:", len(connection.supported_commands))
pause() pause()