From f448abe32625efa201047365bcc66e07c3b05e96 Mon Sep 17 00:00:00 2001 From: Zachary Nisen Date: Fri, 5 Jun 2026 11:26:55 -0600 Subject: [PATCH] Restore vehicle info function --- menu.py | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/menu.py b/menu.py index 66d78d5..4eeec8c 100644 --- a/menu.py +++ b/menu.py @@ -1,6 +1,8 @@ import logging import csv +import time import obd +from datetime import datetime logging.getLogger("obd").setLevel(logging.CRITICAL) @@ -65,7 +67,15 @@ def live_data(connection): if response.is_null(): print(name + ": Not supported") else: - print(name + ":", response.value) + value = response.value + + if name == "Speed": + value = value.to("mile_per_hour") + + elif name == "Coolant Temp": + value = value.to("degF") + + print(name + ":", value) pause() @@ -84,7 +94,8 @@ def vehicle_info(connection): if vin.is_null(): print("VIN: Not available") elif vin.value: - print("VIN:", vin.value) + vin_text = vin.value.decode("utf-8") + print("VIN:", vin_text) else: print("VIN: Not available") @@ -92,11 +103,15 @@ def vehicle_info(connection): def save_log(): - with open("vehicle_log.csv", "w", newline="") as file: + with open("vehicle_log.csv", "a", newline="") as file: writer = csv.writer(file) - writer.writerow(["RPM", "Speed", "Coolant"]) - writer.writerow([850, 0, 195]) + writer.writerow([ + datetime.now(), + 850, + 0, + 195 + ]) print("Log saved to vehicle_log.csv") pause() @@ -143,4 +158,5 @@ def main(): else: print("Invalid choice") + main()