launching openBCI LSL stream from python script
Hi all,
I am trying to launch a LSL stream directly from a python script but cannot get it right.
The following command works perfectly and indicates that no package is missing for LSL:
#
python user.py -p /dev/cu.OpenBCI-DQ007MS3 -a streamer_lsl -d --log
#
Here is the code below
Any idea?
#MODULES
import subprocess
import os
import time
#
# Main Variables OBCI
#
P_Scan = /dev/cu.OpenBCI-DQ007MS3
O_Port = " -p %s" % (P_Scan)
O_Stream = " -a %s" % ("streamer_lsl")
O_Daisy = " -d"
O_Log = " --log"
O_UserFile = "python ~/Git/OpenBCI_Python/user.py"
O_Init = "%s%s%s%s%s" % (O_UserFile, O_Port, O_Stream, O_Daisy, O_Log)
O_Start = "/start"
# Clear Terminal
os.system('cls' if os.name == 'nt' else 'clear')
#
# MAIN TESTS
#
def main():
if P_Scan == None:
print("--> ERROR: ","-"*60)
print("--> No Device Found.")
O_Act = False
else:
try:
print("--> BOARD LAUNCH: ","-"*60)
print("--> using port: %s" % (P_Scan))
#Launch OBCI board streaming
p = subprocess.Popen([O_Init],shell=True,stdout=subprocess.PIPE,stdin=subprocess.PIPE)
p.stdin.write(O_Start)
print("--> OK.")
O_Act = True
except():
print("--> ERROR: ","-"*60)
print("--> CAN'T STREAM WITH OBCI DEVICE.")
O_Act = False
return O_Act
#
if __name__ == '__main__':
main()
#
Comments