Added CSV logging
This commit is contained in:
17
menu.py
17
menu.py
@@ -1,4 +1,5 @@
|
||||
import logging
|
||||
import csv
|
||||
import obd
|
||||
|
||||
logging.getLogger("obd").setLevel(logging.CRITICAL)
|
||||
@@ -90,6 +91,17 @@ def vehicle_info(connection):
|
||||
pause()
|
||||
|
||||
|
||||
def save_log():
|
||||
with open("vehicle_log.csv", "w", newline="") as file:
|
||||
writer = csv.writer(file)
|
||||
|
||||
writer.writerow(["RPM", "Speed", "Coolant"])
|
||||
writer.writerow([850, 0, 195])
|
||||
|
||||
print("Log saved to vehicle_log.csv")
|
||||
pause()
|
||||
|
||||
|
||||
def main():
|
||||
connection = None
|
||||
|
||||
@@ -105,6 +117,7 @@ def main():
|
||||
print("2. Read Codes")
|
||||
print("3. Live Data")
|
||||
print("4. Vehicle Info")
|
||||
print("5. Save vehicle log")
|
||||
print("Q. Quit")
|
||||
|
||||
choice = input("> ")
|
||||
@@ -121,11 +134,13 @@ def main():
|
||||
elif choice == "4":
|
||||
vehicle_info(connection)
|
||||
|
||||
elif choice == "5":
|
||||
save_log()
|
||||
|
||||
elif choice.lower() == "q":
|
||||
break
|
||||
|
||||
else:
|
||||
print("Invalid choice")
|
||||
|
||||
|
||||
main()
|
||||
|
||||
Reference in New Issue
Block a user