Changes

Jump to navigation Jump to search
260 bytes removed ,  11:15, 1 February 2022
Line 83: Line 83:  
</syntaxhighlight>
 
</syntaxhighlight>
   −
A short example for sending lsl streaming data:
+
A short example for receiving lsl data:
 
<syntaxhighlight lang="python" line>
 
<syntaxhighlight lang="python" line>
 
#!/usr/bin/env python
 
#!/usr/bin/env python
   −
import threading
+
from pylsl import StreamInlet, resolve_stream
from pylsl import StreamInfo, StreamOutlet
     −
def getData():
+
streams = resolve_stream('name', 'MyStream')
    while running:
+
#streams = resolve_streams()
        buffer_in = getSensorData()
  −
        send_data = True
  −
        time.sleep(0.001)
     −
info = StreamInfo(
+
inlet = StreamInlet(streams[0])
    name='MyStream',
+
while True:
    type='COP',
+
     sample, timestamp = inlet.pull_sample()
    channel_count=4,
+
    print(timestamp, sample)
     nominal_srate = 200,  
  −
    source_id='BalanceBoard_stream'
  −
    )
  −
outlet = StreamOutlet(info)
  −
 
  −
threading.Thread(target=getData).start()
  −
while running == True:
  −
if send_data:
  −
outlet.push_chunk(buffer_in)
  −
send_data = False
   
</syntaxhighlight>
 
</syntaxhighlight>
  

Navigation menu