-
-
Notifications
You must be signed in to change notification settings - Fork 322
/
brainflow_config_board.py
52 lines (42 loc) · 2.08 KB
/
brainflow_config_board.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import argparse
import time
import brainflow
import numpy as np
from brainflow.board_shim import BoardShim, BrainFlowInputParams
from brainflow.data_filter import DataFilter, FilterTypes, AggOperations
def main ():
parser = argparse.ArgumentParser ()
# use docs to check which parameters are required for specific board, e.g. for Cyton - set serial port
parser.add_argument ('--ip-port', type = int, help = 'ip port', required = False, default = 0)
parser.add_argument ('--ip-protocol', type = int, help = 'ip protocol, check IpProtocolType enum', required = False, default = 0)
parser.add_argument ('--ip-address', type = str, help = 'ip address', required = False, default = '')
parser.add_argument ('--serial-port', type = str, help = 'serial port', required = False, default = '')
parser.add_argument ('--mac-address', type = str, help = 'mac address', required = False, default = '')
parser.add_argument ('--other-info', type = str, help = 'other info', required = False, default = '')
parser.add_argument ('--board-id', type = int, help = 'board id, check docs to get a list of supported boards', required = True)
parser.add_argument ('--log', action = 'store_true')
args = parser.parse_args ()
params = BrainFlowInputParams ()
params.ip_port = args.ip_port
params.serial_port = args.serial_port
params.mac_address = args.mac_address
params.other_info = args.other_info
params.ip_address = args.ip_address
params.ip_protocol = args.ip_protocol
if (args.log):
BoardShim.enable_dev_board_logger ()
else:
BoardShim.disable_board_logger ()
board = BoardShim (args.board_id, params)
board.prepare_session ()
# disable 2nd channel for cyton use real board to check it, emulator ignores commands
if args.board_id == brainflow.board_shim.BoardIds.CYTON_BOARD.value:
board.config_board ('x2100000X')
board.start_stream ()
time.sleep (10)
data = board.get_board_data ()
board.stop_stream ()
board.release_session ()
print (data)
if __name__ == "__main__":
main ()