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/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/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 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/board_controller.h b/src/board_controller/inc/board_controller.h index 2b67a78a4..1e96b3ff3 100644 --- a/src/board_controller/inc/board_controller.h +++ b/src/board_controller/inc/board_controller.h @@ -1,15 +1,8 @@ #pragma once -#ifdef _WIN32 -#define SHARED_EXPORT __declspec(dllexport) -#define CALLING_CONVENTION __cdecl -#else -#define SHARED_EXPORT __attribute__ ((visibility ("default"))) -#define CALLING_CONVENTION -#endif - #include "board_info_getter.h" #include "brainflow_constants.h" +#include "shared_export.h" #ifdef __cplusplus diff --git a/src/board_controller/inc/board_info_getter.h b/src/board_controller/inc/board_info_getter.h index 0c9301577..a21519a13 100644 --- a/src/board_controller/inc/board_info_getter.h +++ b/src/board_controller/inc/board_info_getter.h @@ -1,12 +1,6 @@ #pragma once -#ifdef _WIN32 -#define SHARED_EXPORT __declspec(dllexport) -#define CALLING_CONVENTION __cdecl -#else -#define SHARED_EXPORT __attribute__ ((visibility ("default"))) -#define CALLING_CONVENTION -#endif +#include "shared_export.h" #ifdef __cplusplus extern "C" 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/src/data_handler/inc/data_handler.h b/src/data_handler/inc/data_handler.h index 278bb5202..4ba3f5740 100644 --- a/src/data_handler/inc/data_handler.h +++ b/src/data_handler/inc/data_handler.h @@ -1,14 +1,7 @@ #pragma once -#ifdef _WIN32 -#define SHARED_EXPORT __declspec(dllexport) -#define CALLING_CONVENTION __cdecl -#else -#define SHARED_EXPORT __attribute__ ((visibility ("default"))) -#define CALLING_CONVENTION -#endif - #include "brainflow_constants.h" +#include "shared_export.h" #define MAX_FILTER_ORDER 8 // define it here to show in the docs diff --git a/src/utils/inc/shared_export.h b/src/utils/inc/shared_export.h new file mode 100644 index 000000000..ad837715b --- /dev/null +++ b/src/utils/inc/shared_export.h @@ -0,0 +1,9 @@ +#pragma once + +#ifdef _WIN32 +#define SHARED_EXPORT __declspec(dllexport) +#define CALLING_CONVENTION __cdecl +#else +#define SHARED_EXPORT __attribute__ ((visibility ("default"))) +#define CALLING_CONVENTION +#endif \ No newline at end of file diff --git a/src/utils/inc/shared_export_matlab.h b/src/utils/inc/shared_export_matlab.h new file mode 100644 index 000000000..6a36360ee --- /dev/null +++ b/src/utils/inc/shared_export_matlab.h @@ -0,0 +1,12 @@ +#pragma once + +// matlab uses regexp to parse headers and find function declarations +// this regexp doesnt work with __attribute__ ((visibility ("default"))), solution - build all code +// using shared_export.h but copypaste this file to matlab headers parser instead shared_export.h +#ifdef _WIN32 +#define SHARED_EXPORT __declspec(dllexport) +#define CALLING_CONVENTION __cdecl +#else +#define SHARED_EXPORT +#define CALLING_CONVENTION +#endif 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 ()