Added CSV logging

This commit is contained in:
2026-06-03 14:57:30 -06:00
parent e736ab616b
commit bbec17e15e

17
menu.py
View File

@@ -1,4 +1,5 @@
import logging import logging
import csv
import obd import obd
logging.getLogger("obd").setLevel(logging.CRITICAL) logging.getLogger("obd").setLevel(logging.CRITICAL)
@@ -90,6 +91,17 @@ def vehicle_info(connection):
pause() 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(): def main():
connection = None connection = None
@@ -105,6 +117,7 @@ def main():
print("2. Read Codes") print("2. Read Codes")
print("3. Live Data") print("3. Live Data")
print("4. Vehicle Info") print("4. Vehicle Info")
print("5. Save vehicle log")
print("Q. Quit") print("Q. Quit")
choice = input("> ") choice = input("> ")
@@ -121,11 +134,13 @@ def main():
elif choice == "4": elif choice == "4":
vehicle_info(connection) vehicle_info(connection)
elif choice == "5":
save_log()
elif choice.lower() == "q": elif choice.lower() == "q":
break break
else: else:
print("Invalid choice") print("Invalid choice")
main() main()