launching openBCI LSL stream from python script

compmonkscompmonks zurich
edited March 2017 in Software
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

  • wjcroftwjcroft Mount Shasta, CA
    Mentioning Jeremy @jfrey, the developer.

  • Hi,

    I am not sure to understand what you are trying to achieve here. You want to launch an external python script within a python script?? You could directly use the openbci api and LSL if you need to integrate that to your program, or you can also create a new plugin -- and if you want to launch the command... well, bash is nice ;)

    What is the result of you command? I don't see anything wrong here. If it return directly, it might be due to the fact that the main process return right after the subprocess is created.

    Jeremy



Sign In or Register to comment.