Skip to content

Commit a6d9a60

Browse files
committed
LSL stream button issue resolved
1 parent 07e6079 commit a6d9a60

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

app.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,22 +33,22 @@ def start_lsl():
3333

3434
try:
3535
if sys.platform == "win32":
36-
lsl_process = subprocess.Popen(["python", "chords.py", "--lsl"], stdout=subprocess.PIPE, stderr=subprocess.PIPE, creationflags=subprocess.CREATE_NO_WINDOW, text=True)
36+
lsl_process = subprocess.Popen(["python", "chords.py", "--lsl"], stdout=subprocess.PIPE, stderr=subprocess.PIPE, creationflags=subprocess.CREATE_NO_WINDOW, text=True, bufsize=1)
3737
else:
38-
lsl_process = subprocess.Popen(["python", "chords.py", "--lsl"], stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
38+
lsl_process = subprocess.Popen(["python", "chords.py", "--lsl"], stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True, bufsize=1)
3939

4040
output = lsl_process.stderr.readline().strip()
4141
print(output)
4242

4343
if "No" in output:
4444
lsl_running = False
45-
return jsonify({"lsl_started": False, "lsl_status": "Failed to Start", "lsl_color": "red"})
45+
return render_template("index.html", lsl_started= False, lsl_status= "Failed to Start", lsl_color= "red", apps_enabled=False)
4646
else:
4747
lsl_running = True
48-
return jsonify({"lsl_started": True, "lsl_status": "Running", "lsl_color": "green"})
48+
return render_template("index.html", lsl_started= True, lsl_status= "Running", lsl_color= "green", apps_enabled=True)
4949

5050
except Exception as e:
51-
return jsonify({"lsl_started": False, "lsl_status": f"Error: {e}", "lsl_color": "red"})
51+
return render_template("index.html", lsl_started= False, lsl_status= f"Error: {e}", lsl_color= "red")
5252

5353
def read_npg_output():
5454
global npg_process
@@ -73,8 +73,9 @@ def start_npg():
7373
# Start a separate thread to read npg.py output
7474
threading.Thread(target=read_npg_output, daemon=True).start()
7575

76-
npg_running = True
77-
return render_template("index.html", npg_started=True, npg_status="Running", npg_color="green", apps_enabled=True)
76+
if "NPG WebSocket connected!" in npg_process.stdout.readline().strip():
77+
npg_running = True
78+
return render_template("index.html", npg_started=True, npg_status="Running", npg_color="green", apps_enabled=True)
7879

7980
except Exception as e:
8081
npg_running = False

0 commit comments

Comments
 (0)