Skip to content

Commit 5cf61d1

Browse files
authored
Merge pull request #1101 from OpenBCI/1100-add-tests-for-brainflow-streamer-to-networking-test-kit
Add BrainFlow Streaming Board and Streamer tests to Networking Test Kit
2 parents 8939c6b + 74443a4 commit 5cf61d1

2 files changed

Lines changed: 79 additions & 0 deletions

File tree

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# If BrainFlow Python binding is not installed: pip install brainflow
2+
# BrainFlow Documentation: https://brainflow.readthedocs.io/en/stable/SupportedBoards.html#streaming-board
3+
# When used with the OpenBCI GUI, the same version (or very close) should be used on both sides.
4+
# This test accepts a stream from the Synthetic mode in the OpenBCI GUI.
5+
6+
import time
7+
from brainflow.board_shim import (
8+
BoardShim,
9+
BrainFlowInputParams,
10+
BoardIds,
11+
BrainFlowPresets,
12+
)
13+
from brainflow.data_filter import DataFilter
14+
15+
16+
def main():
17+
BoardShim.enable_dev_board_logger()
18+
19+
# use synthetic board for demo
20+
params = BrainFlowInputParams()
21+
params.ip_port = 6677
22+
params.ip_address = "225.1.1.1"
23+
params.master_board = BoardIds.SYNTHETIC_BOARD
24+
board_id = BoardIds.STREAMING_BOARD
25+
26+
board = BoardShim(board_id, params)
27+
board.prepare_session()
28+
board.start_stream()
29+
time.sleep(10)
30+
data_default = board.get_board_data(preset=BrainFlowPresets.DEFAULT_PRESET)
31+
board.stop_stream()
32+
board.release_session()
33+
DataFilter.write_file(data_default, "default.csv", "w")
34+
print(data_default)
35+
36+
37+
if __name__ == "__main__":
38+
main()
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# If BrainFlow Python binding is not installed: pip install brainflow
2+
# BrainFlow Documentation: https://brainflow.readthedocs.io/en/stable/SupportedBoards.html#streaming-board
3+
# BrainFlow Multiple Streamers Example: https://github.com/brainflow-dev/brainflow/blob/master/python_package/examples/tests/multiple_streamers.py
4+
# When used with the OpenBCI GUI, the same version (or very close) should be used on both sides.
5+
# This test connects directly to an OpenBCI board, or Synthetic board, and streams it out to the OpenBCI GUI.
6+
7+
import time
8+
9+
from brainflow.board_shim import (
10+
BoardShim,
11+
BrainFlowInputParams,
12+
BoardIds,
13+
BrainFlowPresets,
14+
)
15+
from brainflow.data_filter import DataFilter
16+
17+
18+
def main():
19+
BoardShim.enable_dev_board_logger()
20+
21+
# use synthetic board for demo
22+
params = BrainFlowInputParams()
23+
board_id = BoardIds.SYNTHETIC_BOARD.value
24+
25+
presets = BoardShim.get_board_presets(board_id)
26+
print(presets)
27+
28+
board = BoardShim(board_id, params)
29+
board.prepare_session()
30+
board.add_streamer("file://streamer_default.csv:w")
31+
board.add_streamer("streaming_board://225.1.1.1:6677")
32+
board.start_stream()
33+
time.sleep(30)
34+
data_default = board.get_board_data(preset=BrainFlowPresets.DEFAULT_PRESET)
35+
board.stop_stream()
36+
board.release_session()
37+
DataFilter.write_file(data_default, "default.csv", "w")
38+
39+
40+
if __name__ == "__main__":
41+
main()

0 commit comments

Comments
 (0)