Restore vehicle info function
This commit is contained in:
26
menu.py
26
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()
|
||||
|
||||
Reference in New Issue
Block a user