From 6bc107eb90f8b208e3a065b02033d0ad28bcf237 Mon Sep 17 00:00:00 2001 From: Andrey Parfenov Date: Fri, 27 Mar 2020 14:22:05 +0300 Subject: [PATCH 1/2] add configurable timeout for ble devices (#136) * add configurable timeout for ble devices Signed-off-by: Andrey Parfenov --- cpp-package/src/board_shim.cpp | 1 + .../brainflow/brainflow_input_params.cs | 6 ++ .../brainflow_get_data/brainflow_get_data.cs | 4 + docs/SupportedBoards.rst | 22 +++-- .../java/brainflow/BrainFlowInputParams.java | 12 +++ .../brainflow/examples/BrainFlowGetData.java | 4 + .../brainflow/BrainFlowInputParams.m | 2 + python-package/brainflow/board_shim.py | 1 + src/board_controller/board_controller.cpp | 1 + .../inc/brainflow_input_params.h | 8 +- src/board_controller/neuromd/brainbit.cpp | 91 +++++++------------ src/board_controller/neuromd/inc/brainbit.h | 1 + src/board_controller/openbci/ganglion.cpp | 16 +++- .../openbci/ganglion_bglib/helpers.cpp | 7 +- .../ganglion_bglib/inc/ganglion_interface.h | 20 ++++ .../openbci/ganglion_bglib/main.cpp | 15 +-- .../get_data_demo/src/brainflow_get_data.cpp | 13 +++ tests/python/brainflow_get_data.py | 2 + 18 files changed, 145 insertions(+), 81 deletions(-) diff --git a/cpp-package/src/board_shim.cpp b/cpp-package/src/board_shim.cpp index a26e02be6..f355d76da 100644 --- a/cpp-package/src/board_shim.cpp +++ b/cpp-package/src/board_shim.cpp @@ -23,6 +23,7 @@ std::string params_to_string (struct BrainFlowInputParams params) j["ip_address"] = params.ip_address; j["mac_address"] = params.mac_address; j["other_info"] = params.other_info; + j["timeout"] = params.timeout; std::string post_str = j.dump (); return post_str; } diff --git a/csharp-package/brainflow/brainflow/brainflow_input_params.cs b/csharp-package/brainflow/brainflow/brainflow_input_params.cs index 1e1f53039..9f13bed29 100644 --- a/csharp-package/brainflow/brainflow/brainflow_input_params.cs +++ b/csharp-package/brainflow/brainflow/brainflow_input_params.cs @@ -49,6 +49,11 @@ public class BrainFlowInputParams /// [DataMember] public string other_info; + /// + /// timeout for device discovery or connection + /// + [DataMember] + public int timeout; public BrainFlowInputParams () { @@ -58,6 +63,7 @@ public BrainFlowInputParams () ip_port = 0; ip_protocol = (int)IpProtocolType.NONE; other_info = ""; + timeout = 0; } public string to_json () diff --git a/csharp-package/brainflow/brainflow_get_data/brainflow_get_data.cs b/csharp-package/brainflow/brainflow_get_data/brainflow_get_data.cs index 252a1860f..95def2e37 100644 --- a/csharp-package/brainflow/brainflow_get_data/brainflow_get_data.cs +++ b/csharp-package/brainflow/brainflow_get_data/brainflow_get_data.cs @@ -63,6 +63,10 @@ static int parse_args (string[] args, BrainFlowInputParams input_params) { board_id = Convert.ToInt32 (args[i + 1]); } + if (args[i].Equals("--timeout")) + { + input_params.timeout = Convert.ToInt32(args[i + 1]); + } } return board_id; } diff --git a/docs/SupportedBoards.rst b/docs/SupportedBoards.rst index e9edf5d80..8b3fe99a9 100644 --- a/docs/SupportedBoards.rst +++ b/docs/SupportedBoards.rst @@ -6,17 +6,17 @@ Supported Boards To create an instance of BoardShim class for your board check required inputs in the table below: .. csv-table:: Required inputs - :header: "Board", "Board Id", "BrainFlowInputParams.serial_port", "BrainFlowInputParams.mac_address", "BrainFlowInputParams.ip_address", "BrainFlowInputParams.ip_port", "BrainFlowInputParams.ip_protocol", "BrainFlowInputParams.other_info" + :header: "Board", "Board Id", "BrainFlowInputParams.serial_port", "BrainFlowInputParams.mac_address", "BrainFlowInputParams.ip_address", "BrainFlowInputParams.ip_port", "BrainFlowInputParams.ip_protocol", "BrainFlowInputParams.other_info", "BrainFlowInputParams.timeout" - "Streaming Board", "BoardIds.STREAMING_BOARD (-2)", "-", "-", "multicast IP address", "port", "-", "Board Id of master board" - "Synthetic Board", "BoardIds.SYNTHETIC_BOARD (-1)", "-", "-", "-", "-", "-", "-" - "Cyton", "BoardIds.CYTON_BOARD (0)", "dongle serial port(COM3, /dev/ttyUSB0, /dev/cu.usbserial-xxxxxx...)", "-", "-", "-", "-", "-" - "Ganglion", "BoardIds.GANGLION_BOARD (1)", "dongle serial port(COM3, /dev/ttyUSB0...)", "Optional: Ganglion's MAC address", "-", "-", "-", "-" - "Cyton Daisy", "BoardIds.CYTON_DAISY_BOARD (2)", "dongle serial port(COM3, /dev/ttyUSB0, /dev/cu.usbserial-xxxxxx...)", "-", "-", "-", "-", "-" - "Ganglion Wifi", "BoardIds.GANGLION_WIFI_BOARD (4)", "-", "-", "Wifi Shield IP(default 192.168.4.1)", "any local port which is free", "-", "-" - "Cyton Wifi", "BoardIds.CYTON_WIFI_BOARD (5)", "-", "-", "Wifi Shield IP(default 192.168.4.1)", "any local port which is free", "-", "-" - "Cyton Daisy Wifi", "BoardIds.CYTON_DAISY_WIFI_BOARD (6)", "-", "-", "Wifi Shield IP(default 192.168.4.1)", "any local port which is free", "-", "-" - "BrainBit", "BoardIds.BRAINBIT_BOARD (7)", "-", "-", "-", "-", "-", "Serial Number of BrainBit device" + "Streaming Board", "BoardIds.STREAMING_BOARD (-2)", "-", "-", "multicast IP address", "port", "-", "Board Id of master board", "-" + "Synthetic Board", "BoardIds.SYNTHETIC_BOARD (-1)", "-", "-", "-", "-", "-", "-", "-" + "Cyton", "BoardIds.CYTON_BOARD (0)", "dongle serial port(COM3, /dev/ttyUSB0, /dev/cu.usbserial-xxxxxx...)", "-", "-", "-", "-", "-", "-" + "Ganglion", "BoardIds.GANGLION_BOARD (1)", "dongle serial port(COM3, /dev/ttyUSB0...)", "Optional: Ganglion's MAC address", "-", "-", "-", "-", "Timeout for device discovery(default 15sec)" + "Cyton Daisy", "BoardIds.CYTON_DAISY_BOARD (2)", "dongle serial port(COM3, /dev/ttyUSB0, /dev/cu.usbserial-xxxxxx...)", "-", "-", "-", "-", "-", "-" + "Ganglion Wifi", "BoardIds.GANGLION_WIFI_BOARD (4)", "-", "-", "Wifi Shield IP(default 192.168.4.1)", "any local port which is free", "-", "-", "-" + "Cyton Wifi", "BoardIds.CYTON_WIFI_BOARD (5)", "-", "-", "Wifi Shield IP(default 192.168.4.1)", "any local port which is free", "-", "-", "-" + "Cyton Daisy Wifi", "BoardIds.CYTON_DAISY_WIFI_BOARD (6)", "-", "-", "Wifi Shield IP(default 192.168.4.1)", "any local port which is free", "-", "-", "-" + "BrainBit", "BoardIds.BRAINBIT_BOARD (7)", "-", "-", "-", "-", "-", "Serial Number of BrainBit device", "Timeout for device discovery(default 15sec)" Streaming Board @@ -136,6 +136,7 @@ To choose this board in BoardShim constructor please specify: - board_id: 1 - serial_port field of BrainFlowInputParams structure - mac_address field of BrainFlowInputParams structure, if its empty BrainFlow will try to autodiscover Ganglion +- optional: timeout field of BrainFlowInputParams structure, default is 15sec To get Ganglion's MAC address you can use: @@ -297,6 +298,7 @@ To choose this board in BoardShim constructor please specify: - board_id: 7 - other_info field of BrainFlowInputParams structure should contain Serial Number of BrainBit device +- optional: timeout field of BrainFlowInputParams structure, default is 15sec Supported platforms: diff --git a/java-package/brainflow/src/main/java/brainflow/BrainFlowInputParams.java b/java-package/brainflow/src/main/java/brainflow/BrainFlowInputParams.java index 2b66fb326..34573893c 100644 --- a/java-package/brainflow/src/main/java/brainflow/BrainFlowInputParams.java +++ b/java-package/brainflow/src/main/java/brainflow/BrainFlowInputParams.java @@ -13,6 +13,7 @@ public class BrainFlowInputParams public int ip_port; public int ip_protocol; public String other_info; + public int timeout; public BrainFlowInputParams () { @@ -22,6 +23,7 @@ public BrainFlowInputParams () ip_port = 0; ip_protocol = IpProtocolType.NONE.get_code (); other_info = ""; + timeout = 0; } public String to_json () @@ -88,4 +90,14 @@ public void set_other_info (String other_info) { this.other_info = other_info; } + + public void set_timeout (int timeout) + { + this.timeout = timeout; + } + + public int get_timeout () + { + return timeout; + } } diff --git a/java-package/brainflow/src/main/java/brainflow/examples/BrainFlowGetData.java b/java-package/brainflow/src/main/java/brainflow/examples/BrainFlowGetData.java index 62b2a364d..82e96e1af 100644 --- a/java-package/brainflow/src/main/java/brainflow/examples/BrainFlowGetData.java +++ b/java-package/brainflow/src/main/java/brainflow/examples/BrainFlowGetData.java @@ -65,6 +65,10 @@ private static int parse_args (String[] args, BrainFlowInputParams params) { board_id = Integer.parseInt (args[i + 1]); } + if (args[i].equals ("--timeout")) + { + params.timeout = Integer.parseInt (args[i + 1]); + } } return board_id; } diff --git a/matlab-package/brainflow/BrainFlowInputParams.m b/matlab-package/brainflow/BrainFlowInputParams.m index 8b3788a28..df9b0bff0 100644 --- a/matlab-package/brainflow/BrainFlowInputParams.m +++ b/matlab-package/brainflow/BrainFlowInputParams.m @@ -6,6 +6,7 @@ ip_port ip_protocol other_info + timeout end methods function obj = BrainFlowInputParams () @@ -15,6 +16,7 @@ obj.ip_port = 0; obj.ip_protocol = int32 (IpProtocolType.NONE); obj.other_info = ''; + obj.timeout = 0; end function json_string = to_json (obj) json_string = jsonencode(obj); diff --git a/python-package/brainflow/board_shim.py b/python-package/brainflow/board_shim.py index a3c6a6aed..d68cbe194 100755 --- a/python-package/brainflow/board_shim.py +++ b/python-package/brainflow/board_shim.py @@ -70,6 +70,7 @@ def __init__ (self): self.ip_port = 0 self.ip_protocol = IpProtocolType.NONE.value self.other_info = '' + self.timeout = 0 def to_json (self): return json.dumps (self, default = lambda o: o.__dict__, diff --git a/src/board_controller/board_controller.cpp b/src/board_controller/board_controller.cpp index d142e1df7..911a0698b 100644 --- a/src/board_controller/board_controller.cpp +++ b/src/board_controller/board_controller.cpp @@ -316,6 +316,7 @@ int string_to_brainflow_input_params ( params->other_info = config["other_info"]; params->mac_address = config["mac_address"]; params->ip_address = config["ip_address"]; + params->timeout = config["timeout"]; return STATUS_OK; } catch (json::exception &e) diff --git a/src/board_controller/inc/brainflow_input_params.h b/src/board_controller/inc/brainflow_input_params.h index e515764f0..46d86e373 100644 --- a/src/board_controller/inc/brainflow_input_params.h +++ b/src/board_controller/inc/brainflow_input_params.h @@ -19,6 +19,7 @@ struct BrainFlowInputParams int ip_port; int ip_protocol; std::string other_info; + int timeout; BrainFlowInputParams () { @@ -28,13 +29,14 @@ struct BrainFlowInputParams ip_port = 0; ip_protocol = (int)IpProtocolType::NONE; other_info = ""; + timeout = 0; } // default copy constructor and assignment operator are ok, need less operator to use in map bool operator< (const struct BrainFlowInputParams &other) const { - return std::tie (serial_port, mac_address, ip_address, ip_port, ip_protocol, other_info) < - std::tie (other.serial_port, other.mac_address, other.ip_address, other.ip_port, - other.ip_protocol, other.other_info); + return std::tie (serial_port, mac_address, ip_address, ip_port, ip_protocol, other_info, + timeout) < std::tie (other.serial_port, other.mac_address, other.ip_address, + other.ip_port, other.ip_protocol, other.other_info, timeout); } }; \ No newline at end of file diff --git a/src/board_controller/neuromd/brainbit.cpp b/src/board_controller/neuromd/brainbit.cpp index 44dcb55be..e8be98d05 100644 --- a/src/board_controller/neuromd/brainbit.cpp +++ b/src/board_controller/neuromd/brainbit.cpp @@ -465,64 +465,27 @@ void BrainBit::read_thread () } } -void BrainBit::free_listeners () +void BrainBit::free_listener (ListenerHandle lh) { -// different headers(free_listener_handle method) for macos and msvc -#ifdef _WIN32 - if (resistance_listener_t4) - { - free_listener_handle (resistance_listener_t4); - - resistance_listener_t4 = NULL; - } - if (resistance_listener_t3) - { - free_listener_handle (resistance_listener_t3); - resistance_listener_t3 = NULL; - } - if (resistance_listener_o1) - { - free_listener_handle (resistance_listener_o1); - resistance_listener_o1 = NULL; - } - if (resistance_listener_o2) + if (lh) { - free_listener_handle (resistance_listener_o2); - resistance_listener_o2 = NULL; - } - if (battery_listener) - { - free_listener_handle (battery_listener); - battery_listener = NULL; - } + // different headers for macos and msvc +#ifdef _WIN32 + free_listener_handle (lh); +#else + free_length_listener_handle (lh); #endif -#ifdef APPLE - if (resistance_listener_t4) - { - free_length_listener_handle (resistance_listener_t4); - resistance_listener_t4 = NULL; - } - if (resistance_listener_t3) - { - free_length_listener_handle (resistance_listener_t3); - resistance_listener_t3 = NULL; + lh = NULL; } - if (resistance_listener_o1) - { - free_length_listener_handle (resistance_listener_o1); - resistance_listener_o1 = NULL; - } - if (resistance_listener_o2) - { - free_length_listener_handle (resistance_listener_o2); - resistance_listener_o2 = NULL; - } - if (battery_listener) - { - free_length_listener_handle (battery_listener); - battery_listener = NULL; - } -#endif +} + +void BrainBit::free_listeners () +{ + free_listener (resistance_listener_t4); + free_listener (resistance_listener_t3); + free_listener (resistance_listener_o1); + free_listener (resistance_listener_o2); + free_listener (battery_listener); } void BrainBit::free_device () @@ -561,6 +524,12 @@ void BrainBit::free_channels () int BrainBit::find_device (long long serial_number) { + if ((params.timeout < 0) || (params.timeout > 600)) + { + safe_logger (spdlog::level::err, "bad value for timeout"); + return INVALID_ARGUMENTS_ERROR; + } + DeviceEnumerator *enumerator = create_device_enumerator (DeviceTypeBrainbit); if (enumerator == NULL) { @@ -570,7 +539,15 @@ int BrainBit::find_device (long long serial_number) return BOARD_NOT_READY_ERROR; } - int attempts = 35; + int timeout = 15; + if (params.timeout != 0) + { + timeout = params.timeout; + } + safe_logger (spdlog::level::info, "set timeout for device discovery to {}", timeout); + + int sleep_delay = 300; + int attempts = (int)(timeout * 1000.0 / sleep_delay); int found = false; int res = STATUS_OK; DeviceInfo device_info; @@ -579,9 +556,9 @@ int BrainBit::find_device (long long serial_number) if (find_device_info (enumerator, serial_number, &device_info) != 0) { #ifdef _WIN32: - Sleep (300); + Sleep (sleep_delay); #else - usleep (300000); + usleep (sleep_delay * 1000); #endif continue; } diff --git a/src/board_controller/neuromd/inc/brainbit.h b/src/board_controller/neuromd/inc/brainbit.h index 27f713f01..aa84c12e6 100644 --- a/src/board_controller/neuromd/inc/brainbit.h +++ b/src/board_controller/neuromd/inc/brainbit.h @@ -39,6 +39,7 @@ class BrainBit : public Board void free_listeners (); void free_device (); void free_channels (); + void free_listener (ListenerHandle lh); ListenerHandle battery_listener; ListenerHandle resistance_listener_t3; diff --git a/src/board_controller/openbci/ganglion.cpp b/src/board_controller/openbci/ganglion.cpp index 2782b7dac..481113fde 100644 --- a/src/board_controller/openbci/ganglion.cpp +++ b/src/board_controller/openbci/ganglion.cpp @@ -392,7 +392,21 @@ int Ganglion::config_board (char *config) int Ganglion::call_init () { - int res = GanglionLib::initialize ((void *)params.serial_port.c_str ()); + if ((params.timeout < 0) || (params.timeout > 600)) + { + safe_logger (spdlog::level::err, "wrong value for timeout"); + return INVALID_ARGUMENTS_ERROR; + } + int timeout = 15; + if (params.timeout != 0) + { + timeout = params.timeout; + } + safe_logger ( + spdlog::level::info, "use {} as a timeout for device discovery and for callbacks", timeout); + + struct GanglionLib::GanglionInputData input_data (timeout, params.serial_port.c_str ()); + int res = GanglionLib::initialize ((void *)&input_data); if (res != (int)GanglionLib::CustomExitCodes::STATUS_OK) { safe_logger (spdlog::level::err, "failed to init GanglionLib {}", res); diff --git a/src/board_controller/openbci/ganglion_bglib/helpers.cpp b/src/board_controller/openbci/ganglion_bglib/helpers.cpp index 25fd3c3a4..0a947c1e2 100644 --- a/src/board_controller/openbci/ganglion_bglib/helpers.cpp +++ b/src/board_controller/openbci/ganglion_bglib/helpers.cpp @@ -23,6 +23,7 @@ namespace GanglionLib { extern volatile int exit_code; + extern int timeout; extern volatile bd_addr connect_addr; extern volatile uint8 connection; extern volatile uint16 client_char_handle; @@ -82,7 +83,7 @@ namespace GanglionLib // send command to connect state = State::INITIAL_CONNECTION; ble_cmd_gap_connect_direct (&connect_addr, gap_address_type_random, 40, 60, 100, 0); - int res = wait_for_callback (15); + int res = wait_for_callback (timeout); if (res != (int)GanglionLib::STATUS_OK) { return res; @@ -94,7 +95,7 @@ namespace GanglionLib ble_cmd_attclient_read_by_group_type ( connection, FIRST_HANDLE, LAST_HANDLE, 2, primary_service_uuid); - res = wait_for_callback (15); + res = wait_for_callback (timeout); if (res != (int)GanglionLib::STATUS_OK) { return res; @@ -107,7 +108,7 @@ namespace GanglionLib exit_code = (int)GanglionLib::SYNC_ERROR; ble_cmd_attclient_attribute_write (connection, client_char_handle, 2, &configuration); ble_cmd_attclient_execute_write (connection, 1); - return wait_for_callback (5); + return wait_for_callback (timeout); } int wait_for_callback (int num_seconds) diff --git a/src/board_controller/openbci/ganglion_bglib/inc/ganglion_interface.h b/src/board_controller/openbci/ganglion_bglib/inc/ganglion_interface.h index 01bf7e427..341ad0927 100644 --- a/src/board_controller/openbci/ganglion_bglib/inc/ganglion_interface.h +++ b/src/board_controller/openbci/ganglion_bglib/inc/ganglion_interface.h @@ -27,6 +27,26 @@ namespace GanglionLib memcpy (data, other.data, sizeof (unsigned char) * 20); } }; + + // just to pass two args to initialize + struct GanglionInputData + { + int timeout; + char uart_port[1024]; + + GanglionInputData (int timeout, const char *uart_port) + { + this->timeout = timeout; + strcpy (this->uart_port, uart_port); + } + + GanglionInputData (const GanglionInputData &other) + { + timeout = other.timeout; + strcpy (uart_port, other.uart_port); + } + }; + #pragma pack(pop) enum CustomExitCodes diff --git a/src/board_controller/openbci/ganglion_bglib/main.cpp b/src/board_controller/openbci/ganglion_bglib/main.cpp index b8e17c85f..c1fea2f71 100644 --- a/src/board_controller/openbci/ganglion_bglib/main.cpp +++ b/src/board_controller/openbci/ganglion_bglib/main.cpp @@ -17,6 +17,7 @@ namespace GanglionLib { volatile int exit_code = (int)GanglionLib::SYNC_ERROR; char uart_port[1024]; + int timeout = 15; std::queue data_queue; volatile bd_addr connect_addr; volatile uint8 connection = -1; @@ -48,7 +49,9 @@ namespace GanglionLib { return (int)CustomExitCodes::PORT_OPEN_ERROR; } - strcpy (uart_port, (const char *)param); + struct GanglionInputData *input = (struct GanglionInputData *)param; + strcpy (uart_port, input->uart_port); + timeout = input->timeout; bglib_output = output; exit_code = (int)CustomExitCodes::SYNC_ERROR; initialized = true; @@ -71,7 +74,7 @@ namespace GanglionLib state = State::OPEN_CALLED; ble_cmd_gap_discover (gap_discover_observation); - res = wait_for_callback (15); + res = wait_for_callback (timeout); if (res != (int)CustomExitCodes::STATUS_OK) { return res; @@ -150,7 +153,7 @@ namespace GanglionLib connection, ganglion_handle_send, 1, (uint8 *)"s"); } }); - int res = wait_for_callback (30); + int res = wait_for_callback (timeout); stop_config_thread = true; config_thread.join (); // need to remove generated by thread above messages from serial port buffer @@ -192,9 +195,7 @@ namespace GanglionLib state = State::WRITE_TO_CLIENT_CHAR; exit_code = (int)GanglionLib::SYNC_ERROR; ble_cmd_attclient_attribute_write (connection, client_char_handle, 2, &configuration); - // according to their docs timeout can be up to 30sec but its too long for us and it should - // be triggered much faster - res = wait_for_callback (30); + res = wait_for_callback (timeout); if (res == (int)CustomExitCodes::STATUS_OK) { should_stop_stream = false; @@ -275,7 +276,7 @@ namespace GanglionLib return (int)CustomExitCodes::SEND_CHARACTERISTIC_NOT_FOUND_ERROR; } ble_cmd_attclient_attribute_write (connection, ganglion_handle_send, len, (uint8 *)config); - return wait_for_callback (30); + return wait_for_callback (timeout); } int release (void *param) diff --git a/tests/cpp/get_data_demo/src/brainflow_get_data.cpp b/tests/cpp/get_data_demo/src/brainflow_get_data.cpp index 675ae8556..f1e958431 100644 --- a/tests/cpp/get_data_demo/src/brainflow_get_data.cpp +++ b/tests/cpp/get_data_demo/src/brainflow_get_data.cpp @@ -170,6 +170,19 @@ bool parse_args (int argc, char *argv[], struct BrainFlowInputParams *params, in return false; } } + if (std::string (argv[i]) == std::string ("--timeout")) + { + if (i + 1 < argc) + { + i++; + params->timeout = std::stoi (std::string (argv[i])); + } + else + { + std::cerr << "missed argument" << std::endl; + return false; + } + } if (std::string (argv[i]) == std::string ("--other-info")) { if (i + 1 < argc) diff --git a/tests/python/brainflow_get_data.py b/tests/python/brainflow_get_data.py index cfc370cbb..63ed7a2cc 100644 --- a/tests/python/brainflow_get_data.py +++ b/tests/python/brainflow_get_data.py @@ -10,6 +10,7 @@ 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 ('--timeout', type = int, help = 'timeout for device discovery or connection', required = False, default = 0) 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 = '') @@ -28,6 +29,7 @@ def main (): params.other_info = args.other_info params.ip_address = args.ip_address params.ip_protocol = args.ip_protocol + params.timeout = args.timeout if (args.log): BoardShim.enable_dev_board_logger () From 4e246c1a4afc72a306a5c0510ff135a18e615879 Mon Sep 17 00:00:00 2001 From: Andrey Parfenov Date: Fri, 27 Mar 2020 14:22:29 +0300 Subject: [PATCH 2/2] fix matlab regexp parser issue (#135) * fix matlab regexp parser issue Signed-off-by: Andrey Parfenov --- CMakeLists.txt | 6 ++++++ docs/BuildBrainFlow.rst | 10 +++++++--- docs/UserAPI.rst | 6 ++++++ matlab-package/brainflow/BoardShim.m | 6 +++--- matlab-package/brainflow/DataFilter.m | 6 +++--- src/board_controller/inc/board_controller.h | 9 +-------- src/board_controller/inc/board_info_getter.h | 8 +------- src/data_handler/inc/data_handler.h | 9 +-------- src/utils/inc/shared_export.h | 9 +++++++++ src/utils/inc/shared_export_matlab.h | 12 ++++++++++++ 10 files changed, 49 insertions(+), 32 deletions(-) create mode 100644 src/utils/inc/shared_export.h create mode 100644 src/utils/inc/shared_export_matlab.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 45729d6b4..7249c54a5 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -239,6 +239,7 @@ add_library ( target_include_directories ( ${BRAINFLOW_CPP_BINDING_NAME} PRIVATE ${CMAKE_HOME_DIRECTORY}/src/board_controller/inc + ${CMAKE_HOME_DIRECTORY}/src/utils/inc ${CMAKE_HOME_DIRECTORY}/src/data_handler/inc ${CMAKE_HOME_DIRECTORY}/cpp-package/src/inc ${CMAKE_HOME_DIRECTORY}/third_party/json @@ -261,6 +262,7 @@ if (MSVC) COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_HOME_DIRECTORY}/src/board_controller/inc/board_controller.h" "${CMAKE_HOME_DIRECTORY}/matlab-package/brainflow/inc/board_controller.h" COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_HOME_DIRECTORY}/src/board_controller/inc/board_info_getter.h" "${CMAKE_HOME_DIRECTORY}/matlab-package/brainflow/inc/board_info_getter.h" COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_HOME_DIRECTORY}/src/board_controller/inc/brainflow_constants.h" "${CMAKE_HOME_DIRECTORY}/matlab-package/brainflow/inc/brainflow_constants.h" + COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_HOME_DIRECTORY}/src/utils/inc/shared_export_matlab.h" "${CMAKE_HOME_DIRECTORY}/matlab-package/brainflow/inc/shared_export.h" COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_HOME_DIRECTORY}/third_party/neurosdk/lib/${NEUROSDK_LIB_NAME}.dll" "${CMAKE_HOME_DIRECTORY}/csharp-package/brainflow/brainflow/lib/${NEUROSDK_LIB_NAME}.dll" COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_HOME_DIRECTORY}/third_party/neurosdk/lib/${NEUROSDK_LIB_NAME}.dll" "${CMAKE_HOME_DIRECTORY}/python-package/brainflow/lib/${NEUROSDK_LIB_NAME}.dll" COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_HOME_DIRECTORY}/third_party/neurosdk/lib/${NEUROSDK_LIB_NAME}.dll" "${CMAKE_HOME_DIRECTORY}/java-package/brainflow/src/main/resources/${NEUROSDK_LIB_NAME}.dll" @@ -274,6 +276,7 @@ if (MSVC) COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_HOME_DIRECTORY}/compiled/$/${DATA_HANDLER_COMPILED_NAME}" "${CMAKE_HOME_DIRECTORY}/matlab-package/brainflow/lib/${DATA_HANDLER_COMPILED_NAME}" COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_HOME_DIRECTORY}/src/board_controller/inc/brainflow_constants.h" "${CMAKE_HOME_DIRECTORY}/matlab-package/brainflow/inc/brainflow_constants.h" COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_HOME_DIRECTORY}/src/data_handler/inc/data_handler.h" "${CMAKE_HOME_DIRECTORY}/matlab-package/brainflow/inc/data_handler.h" + COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_HOME_DIRECTORY}/src/utils/inc/shared_export_matlab.h" "${CMAKE_HOME_DIRECTORY}/matlab-package/brainflow/inc/shared_export.h" ) endif (MSVC) if (UNIX) @@ -284,6 +287,7 @@ if (UNIX) COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_HOME_DIRECTORY}/compiled/${BOARD_CONTROLLER_COMPILED_NAME}" "${CMAKE_HOME_DIRECTORY}/csharp-package/brainflow/brainflow/${BOARD_CONTROLLER_COMPILED_NAME}" COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_HOME_DIRECTORY}/src/board_controller/inc/board_controller.h" "${CMAKE_HOME_DIRECTORY}/matlab-package/brainflow/inc/board_controller.h" COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_HOME_DIRECTORY}/src/board_controller/inc/board_info_getter.h" "${CMAKE_HOME_DIRECTORY}/matlab-package/brainflow/inc/board_info_getter.h" + COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_HOME_DIRECTORY}/src/utils/inc/shared_export_matlab.h" "${CMAKE_HOME_DIRECTORY}/matlab-package/brainflow/inc/shared_export.h" COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_HOME_DIRECTORY}/src/board_controller/inc/brainflow_constants.h" "${CMAKE_HOME_DIRECTORY}/matlab-package/brainflow/inc/brainflow_constants.h" COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_HOME_DIRECTORY}/compiled/${BOARD_CONTROLLER_COMPILED_NAME}" "${CMAKE_HOME_DIRECTORY}/matlab-package/brainflow/lib/${BOARD_CONTROLLER_COMPILED_NAME}" ) @@ -294,6 +298,7 @@ if (UNIX) COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_HOME_DIRECTORY}/compiled/${DATA_HANDLER_COMPILED_NAME}" "${CMAKE_HOME_DIRECTORY}/csharp-package/brainflow/brainflow/lib/${DATA_HANDLER_COMPILED_NAME}" COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_HOME_DIRECTORY}/src/board_controller/inc/brainflow_constants.h" "${CMAKE_HOME_DIRECTORY}/matlab-package/brainflow/inc/brainflow_constants.h" COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_HOME_DIRECTORY}/src/data_handler/inc/data_handler.h" "${CMAKE_HOME_DIRECTORY}/matlab-package/brainflow/inc/data_handler.h" + COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_HOME_DIRECTORY}/src/utils/inc/shared_export_matlab.h" "${CMAKE_HOME_DIRECTORY}/matlab-package/brainflow/inc/shared_export.h" COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_HOME_DIRECTORY}/compiled/${DATA_HANDLER_COMPILED_NAME}" "${CMAKE_HOME_DIRECTORY}/matlab-package/brainflow/lib/${DATA_HANDLER_COMPILED_NAME}" ) endif (UNIX) @@ -343,6 +348,7 @@ install ( ${CMAKE_HOME_DIRECTORY}/src/board_controller/inc/brainflow_constants.h ${CMAKE_HOME_DIRECTORY}/src/board_controller/inc/board_info_getter.h ${CMAKE_HOME_DIRECTORY}/src/board_controller/inc/brainflow_input_params.h + ${CMAKE_HOME_DIRECTORY}/src/utils/inc/shared_export.h ${CMAKE_HOME_DIRECTORY}/src/data_handler/inc/data_handler.h ${CMAKE_HOME_DIRECTORY}/cpp-package/src/inc/data_filter.h ${CMAKE_HOME_DIRECTORY}/cpp-package/src/inc/board_shim.h diff --git a/docs/BuildBrainFlow.rst b/docs/BuildBrainFlow.rst index 9bca0353e..3a47b9832 100644 --- a/docs/BuildBrainFlow.rst +++ b/docs/BuildBrainFlow.rst @@ -62,10 +62,14 @@ You are able to download jar files directly from `release page