Restore vehicle info function

This commit is contained in:
2026-06-05 11:26:55 -06:00
parent bbec17e15e
commit f448abe326

26
menu.py
View File

@@ -1,6 +1,8 @@
import logging import logging
import csv import csv
import time
import obd import obd
from datetime import datetime
logging.getLogger("obd").setLevel(logging.CRITICAL) logging.getLogger("obd").setLevel(logging.CRITICAL)
@@ -65,7 +67,15 @@ def live_data(connection):
if response.is_null(): if response.is_null():
print(name + ": Not supported") print(name + ": Not supported")
else: 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() pause()
@@ -84,7 +94,8 @@ def vehicle_info(connection):
if vin.is_null(): if vin.is_null():
print("VIN: Not available") print("VIN: Not available")
elif vin.value: elif vin.value:
print("VIN:", vin.value) vin_text = vin.value.decode("utf-8")
print("VIN:", vin_text)
else: else:
print("VIN: Not available") print("VIN: Not available")
@@ -92,11 +103,15 @@ def vehicle_info(connection):
def save_log(): 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 = csv.writer(file)
writer.writerow(["RPM", "Speed", "Coolant"]) writer.writerow([
writer.writerow([850, 0, 195]) datetime.now(),
850,
0,
195
])
print("Log saved to vehicle_log.csv") print("Log saved to vehicle_log.csv")
pause() pause()
@@ -143,4 +158,5 @@ def main():
else: else:
print("Invalid choice") print("Invalid choice")
main() main()