Skip to content

Commit

Permalink
merge
Browse files Browse the repository at this point in the history
  • Loading branch information
Explorergt92 committed May 18, 2023
2 parents 0b628e2 + d4cfd91 commit 878869a
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 4 deletions.
4 changes: 0 additions & 4 deletions air_fuel_datastream.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@
import matplotlib.pyplot as plt
import matplotlib.animation as animation
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg
from config import SERIAL_PORT, BAUD_RATE

# Connect to the ELM327 device
connection = obd.OBD(portstr=SERIAL_PORT, baudrate=BAUD_RATE)

# Create a tkinter window
root = Tk()
Expand Down
29 changes: 29 additions & 0 deletions voice/elm327.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from datastreams.flask_air_fuel_datastream import start_datastream, app
from voice.voice_recognition import (
recognize_speech,
recognize_command,
tts_output,
handle_common_voice_commands,
)
Expand Down Expand Up @@ -36,6 +37,7 @@ def handle_voice_commands_elm327(user_object_id):
wakeup_phrases = ["wake up", "i need your help", "start listening"]

standby_mode = False
datastream_process = None

while True:
if not standby_mode:
Expand Down Expand Up @@ -91,6 +93,7 @@ def handle_voice_commands_elm327(user_object_id):
tts_output("The report has been sent to your email.")
else:
response = send_command(ser, cmd)
print(f"Raw response: {response}")
if "NO DATA" not in response:
value = None
if cmd == "0105":
Expand Down Expand Up @@ -128,6 +131,32 @@ def handle_voice_commands_elm327(user_object_id):
tts_output(chatgpt_response)
else:
print(f"{text} not available.")

elif cmd == "START_DATASTREAM":
if datastream_process is None:
print("Starting datastream...")
tts_output("Starting datastream...")
datastream_process = subprocess.Popen(
["python", "datastreams/air_fuel_datastream.py"],
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
text=True,
)
else:
print("Datastream is already running.")
tts_output("Datastream is already running.")

elif cmd == "STOP_DATASTREAM":
if datastream_process is not None:
print("Stopping datastream...")
tts_output("Stopping datastream...")
datastream_process.terminate()
datastream_process = None
else:
print("Datastream is not running.")
tts_output("Datastream is not running.")

else:
print("Command not recognized. Please try again.")
else:
Expand Down

0 comments on commit 878869a

Please sign in to comment.