Skip to content

Commit

Permalink
add support for multiple internal buffers (#510)
Browse files Browse the repository at this point in the history
* add multiple buffers

Signed-off-by: Andrey Parfenov <[email protected]>
  • Loading branch information
Andrey1994 authored Jul 25, 2022
1 parent 06a015e commit 9f069c7
Show file tree
Hide file tree
Showing 161 changed files with 5,541 additions and 2,602 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/clang_format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: Run clang-format
uses: DoozyX/clang-format-lint-action@v0.11
uses: DoozyX/clang-format-lint-action@v0.13
with:
source: 'src'
exclude: './third_party'
extensions: 'h,cpp,c'
clangFormatVersion: 11
clangFormatVersion: 12.0.1
inplace: False
8 changes: 5 additions & 3 deletions .github/workflows/run_unix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,9 @@ jobs:
env:
LD_LIBRARY_PATH: ${{ github.workspace }}/installed/lib
- name: Synthetic Python
run: sudo -H python3 $GITHUB_WORKSPACE/python_package/examples/tests/brainflow_get_data.py --board-id -1 --streamer-params file://$GITHUB_WORKSPACE/test.csv:w
run: sudo -H python3 $GITHUB_WORKSPACE/python_package/examples/tests/brainflow_get_data.py --board-id -1
- name: Synthetic Python Multiple Buffers
run: sudo -H python3 $GITHUB_WORKSPACE/python_package/examples/tests/multiple_buffers.py
- name: Synthetic Cpp
run: $GITHUB_WORKSPACE/cpp_package/examples/get_data/build/brainflow_get_data --board-id -1
env:
Expand Down Expand Up @@ -175,9 +177,9 @@ jobs:
env:
LD_LIBRARY_PATH: ${{ github.workspace }}/installed/lib
- name: Streaming Python
run: sudo -H python3 $GITHUB_WORKSPACE/emulator/brainflow_emulator/streaming_board_emulator.py python3 $GITHUB_WORKSPACE/python_package/examples/tests/brainflow_get_data.py --board-id -2 --ip-address 225.1.1.1 --ip-port 6677 --other-info -1
run: sudo -H python3 $GITHUB_WORKSPACE/emulator/brainflow_emulator/streaming_board_emulator.py python3 $GITHUB_WORKSPACE/python_package/examples/tests/brainflow_get_data.py --board-id -2 --ip-address 225.1.1.1 --ip-port 6677 --master-board -1
- name: Streaming Python Markers
run: sudo -H python3 $GITHUB_WORKSPACE/emulator/brainflow_emulator/streaming_board_emulator.py python3 $GITHUB_WORKSPACE/python_package/examples/tests/markers.py --board-id -2 --ip-address 225.1.1.1 --ip-port 6677 --other-info -1
run: sudo -H python3 $GITHUB_WORKSPACE/emulator/brainflow_emulator/streaming_board_emulator.py python3 $GITHUB_WORKSPACE/python_package/examples/tests/markers.py --board-id -2 --ip-address 225.1.1.1 --ip-port 6677 --master-board -1
- name: Denoising Python
run: sudo -H python3 $GITHUB_WORKSPACE/python_package/examples/tests/denoising.py
- name: Serialization Python
Expand Down
9 changes: 0 additions & 9 deletions .github/workflows/run_windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,6 @@ jobs:
- name: Cyton Windows Python Test Commands
run: python %GITHUB_WORKSPACE%\emulator\brainflow_emulator\cyton_windows.py python %GITHUB_WORKSPACE%\python_package\examples\tests\cyton_commands.py --serial-port
shell: cmd
- name: Cyton Windows Python Test with Streamer
run: python %GITHUB_WORKSPACE%\emulator\brainflow_emulator\cyton_windows.py python %GITHUB_WORKSPACE%\python_package\examples\tests\brainflow_get_data.py --board-id 0 --streamer-params file://file_streamer.csv:w --serial-port
shell: cmd
- name: Cyton Multiboard Windows Python Test
run: python %GITHUB_WORKSPACE%\emulator\brainflow_emulator\cyton_windows.py python %GITHUB_WORKSPACE%\python_package\examples\tests\brainflow_multiboard_get_data.py --board-id 0 --serial-port
shell: cmd
Expand All @@ -170,9 +167,6 @@ jobs:
cd %GITHUB_WORKSPACE%\rust_package\brainflow
cargo run --example=markers
shell: cmd
- name: Synthetic Windows Python Test with Streamer
run: python %GITHUB_WORKSPACE%\python_package\examples\tests\brainflow_get_data.py --board-id -1 --streamer-params file://file_streamer.csv:w
shell: cmd
- name: Synthetic Windows Cpp Test
run: .\cpp_package\examples\get_data\build\Release\brainflow_get_data.exe --board-id -1
shell: cmd
Expand All @@ -184,9 +178,6 @@ jobs:
- name: Cyton Daisy Windows Python Test
run: python %GITHUB_WORKSPACE%\emulator\brainflow_emulator\cyton_windows.py python %GITHUB_WORKSPACE%\python_package\examples\tests\brainflow_get_data.py --board-id 2 --serial-port
shell: cmd
- name: Cyton Daisy Windows Python Test with Streamer
run: python %GITHUB_WORKSPACE%\emulator\brainflow_emulator\cyton_windows.py python %GITHUB_WORKSPACE%\python_package\examples\tests\brainflow_get_data.py --board-id 2 --streamer-params file://file_streamer.csv:w --serial-port
shell: cmd
- name: Cyton Daisy Multiboard Windows Python Test
run: python %GITHUB_WORKSPACE%\emulator\brainflow_emulator\cyton_windows.py python %GITHUB_WORKSPACE%\python_package\examples\tests\brainflow_multiboard_get_data.py --board-id 2 --serial-port
shell: cmd
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/valgrind.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ jobs:
env:
LD_LIBRARY_PATH: $GITHUB_WORKSPACE/installed/lib
- name: Streaming Cpp
run: sudo -H python3 $GITHUB_WORKSPACE/emulator/brainflow_emulator/streaming_board_emulator.py valgrind --error-exitcode=1 --track-origins=yes --leak-check=full $GITHUB_WORKSPACE/cpp_package/examples/get_data/build/brainflow_get_data --board-id -2 --ip-address 225.1.1.1 --ip-port 6677 --other-info -1
run: sudo -H python3 $GITHUB_WORKSPACE/emulator/brainflow_emulator/streaming_board_emulator.py valgrind --error-exitcode=1 --track-origins=yes --leak-check=full $GITHUB_WORKSPACE/cpp_package/examples/get_data/build/brainflow_get_data --board-id -2 --ip-address 225.1.1.1 --ip-port 6677 --master-board -1
- name: Cyton Cpp Markers
run: sudo -H python3 $GITHUB_WORKSPACE/emulator/brainflow_emulator/cyton_linux.py valgrind --error-exitcode=1 --track-origins=yes --leak-check=full $GITHUB_WORKSPACE/cpp_package/examples/get_data/build/markers --board-id 0 --serial-port
- name: Synthetic Cpp
Expand All @@ -114,7 +114,7 @@ jobs:
env:
LD_LIBRARY_PATH: $GITHUB_WORKSPACE/installed/lib
- name: Streaming Cpp Markers
run: sudo -H python3 $GITHUB_WORKSPACE/emulator/brainflow_emulator/streaming_board_emulator.py valgrind --error-exitcode=1 --track-origins=yes --leak-check=full $GITHUB_WORKSPACE/cpp_package/examples/get_data/build/markers --board-id -2 --ip-address 225.1.1.1 --ip-port 6677 --other-info -1
run: sudo -H python3 $GITHUB_WORKSPACE/emulator/brainflow_emulator/streaming_board_emulator.py valgrind --error-exitcode=1 --track-origins=yes --leak-check=full $GITHUB_WORKSPACE/cpp_package/examples/get_data/build/markers --board-id -2 --ip-address 225.1.1.1 --ip-port 6677 --master-board -1
- name: Denoising Cpp
run: valgrind --error-exitcode=1 --track-origins=yes --leak-check=full $GITHUB_WORKSPACE/cpp_package/examples/signal_processing/build/denoising
env:
Expand Down
7 changes: 5 additions & 2 deletions cpp_package/build.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,16 @@ else (CMAKE_SIZEOF_VOID_P EQUAL 8)
endif (APPLE)
endif (CMAKE_SIZEOF_VOID_P EQUAL 8)

add_library (
${BRAINFLOW_CPP_BINDING_NAME} STATIC
SET (CPP_BINDING_SRC
${CMAKE_HOME_DIRECTORY}/cpp_package/src/board_shim.cpp
${CMAKE_HOME_DIRECTORY}/cpp_package/src/ml_model.cpp
${CMAKE_HOME_DIRECTORY}/cpp_package/src/data_filter.cpp
)

add_library (
${BRAINFLOW_CPP_BINDING_NAME} STATIC ${CPP_BINDING_SRC}
)

target_include_directories (
${BRAINFLOW_CPP_BINDING_NAME} PRIVATE
${CMAKE_HOME_DIRECTORY}/src/board_controller/inc
Expand Down
19 changes: 19 additions & 0 deletions cpp_package/examples/get_data/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,23 @@ target_link_libraries (
${MLModulePath}
${DataHandlerPath}
${BoardControllerPath}
)

add_executable (
get_data_muse
src/get_data_muse.cpp
)

target_include_directories (
get_data_muse PUBLIC
${brainflow_INCLUDE_DIRS}
)

target_link_libraries (
get_data_muse PUBLIC
# for some systems(ubuntu for example) order matters
${BrainflowPath}
${MLModulePath}
${DataHandlerPath}
${BoardControllerPath}
)
27 changes: 27 additions & 0 deletions cpp_package/examples/get_data/src/brainflow_get_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ int main (int argc, char *argv[])
{
BoardShim::enable_dev_board_logger ();

BoardShim::get_board_presets (-1);
struct BrainFlowInputParams params;
int board_id = 0;
if (!parse_args (argc, argv, &params, &board_id))
Expand Down Expand Up @@ -196,6 +197,32 @@ bool parse_args (int argc, char *argv[], struct BrainFlowInputParams *params, in
return false;
}
}
if (std::string (argv[i]) == std::string ("--master-board"))
{
if (i + 1 < argc)
{
i++;
params->master_board = std::stoi (std::string (argv[i]));
}
else
{
std::cerr << "missed argument" << std::endl;
return false;
}
}
if (std::string (argv[i]) == std::string ("--preset"))
{
if (i + 1 < argc)
{
i++;
params->preset = std::stoi (std::string (argv[i]));
}
else
{
std::cerr << "missed argument" << std::endl;
return false;
}
}
}
if (!board_id_found)
{
Expand Down
58 changes: 58 additions & 0 deletions cpp_package/examples/get_data/src/get_data_muse.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#include <iostream>
#include <stdlib.h>
#include <string>

#ifdef _WIN32
#include <windows.h>
#else
#include <unistd.h>
#endif

#include "board_shim.h"
#include "data_filter.h"
#include "ml_model.h"

using namespace std;


int main (int argc, char *argv[])
{
BoardShim::enable_dev_board_logger ();

struct BrainFlowInputParams params;
int board_id = (int)BoardIds::MUSE_S_BOARD;
int res = 0;

BoardShim *board = new BoardShim (board_id, params);

try
{
board->prepare_session ();
board->config_board ("p61");
board->add_streamer ("file://streamer_default.csv:w");
board->add_streamer ("file://streamer_aux.csv:w", (int)BrainFlowPresets::AUXILIARY_PRESET);
board->add_streamer ("file://streamer_anc.csv:w", (int)BrainFlowPresets::ANCILLARY_PRESET);
board->start_stream ();

#ifdef _WIN32
Sleep (10000);
#else
sleep (10);
#endif
board->stop_stream ();
board->release_session ();
}
catch (const BrainFlowException &err)
{
BoardShim::log_message ((int)LogLevels::LEVEL_ERROR, err.what ());
res = err.exit_code;
if (board->is_prepared ())
{
board->release_session ();
}
}

delete board;

return res;
}
4 changes: 2 additions & 2 deletions cpp_package/examples/get_data/src/get_data_twice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@

using namespace std;

bool parse_args (int argc, char *argv[], struct BrainFlowInputParams *params, int *board_id);


int main (int argc, char *argv[])
{
Expand All @@ -33,7 +31,9 @@ int main (int argc, char *argv[])
try
{
board->prepare_session ();
board->add_streamer ("file://streamer_default.csv:w");
board->start_stream ();
board->add_streamer ("file://streamer_aux.csv:w", (int)BrainFlowPresets::AUXILIARY_PRESET);

#ifdef _WIN32
Sleep (5000);
Expand Down
26 changes: 26 additions & 0 deletions cpp_package/examples/get_data/src/markers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,32 @@ bool parse_args (int argc, char *argv[], struct BrainFlowInputParams *params, in
return false;
}
}
if (std::string (argv[i]) == std::string ("--master-board"))
{
if (i + 1 < argc)
{
i++;
params->master_board = std::stoi (std::string (argv[i]));
}
else
{
std::cerr << "missed argument" << std::endl;
return false;
}
}
if (std::string (argv[i]) == std::string ("--preset"))
{
if (i + 1 < argc)
{
i++;
params->preset = std::stoi (std::string (argv[i]));
}
else
{
std::cerr << "missed argument" << std::endl;
return false;
}
}
}
if (!board_id_found)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ int main (int argc, char *argv[])
#endif

board->stop_stream ();
BrainFlowArray<double, 2> data = board->get_board_data (32);
BrainFlowArray<double, 2> data = board->get_board_data ();
board->release_session ();

double *downsampled_data = NULL;
Expand Down
Loading

0 comments on commit 9f069c7

Please sign in to comment.