Skip to content

Commit

Permalink
add linux support
Browse files Browse the repository at this point in the history
  • Loading branch information
yecq committed Jan 17, 2025
1 parent 6f04690 commit a5b1d33
Show file tree
Hide file tree
Showing 17 changed files with 72 additions and 25 deletions.
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ option (USE_LIBFTDI "USE_LIBFTDI" OFF)
option (USE_OPENMP "USE_OPENMP" OFF)
option (WARNINGS_AS_ERRORS "WARNINGS_AS_ERRORS" OFF)
option (BUILD_OYMOTION_SDK "BUILD_OYMOTION_SDK" OFF)
option (BUILD_SYNCHRONI_SDK "BUILD_SYNCHRONI_SDK" OFF)
option (BUILD_SYNCHRONI_SDK "BUILD_SYNCHRONI_SDK" ON)
option (BUILD_BLUETOOTH "BUILD_BLUETOOTH" OFF)
option (BUILD_BLE "BUILD_BLE" OFF)
option (BUILD_ONNX "BUILD_ONNX" OFF)
Expand Down Expand Up @@ -57,6 +57,8 @@ if (BUILD_TESTS)
include (${CMAKE_CURRENT_SOURCE_DIR}/src/tests/build.cmake)
endif (BUILD_TESTS)

#add_subdirectory (${CMAKE_CURRENT_SOURCE_DIR}/cpp_package/examples/get_data)

include (CMakePackageConfigHelpers)

write_basic_package_version_file (
Expand Down
4 changes: 4 additions & 0 deletions src/board_controller/board_controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,10 @@ int prepare_session (int board_id, const char *json_brainflow_input_params)
break;
case BoardIds::OB5000_8_CHANNELS_BOARD:
board = std::shared_ptr<Board> (new SynchroniBoard (board_id, params));
break;
case BoardIds::OB3000_24_CHANNELS_BOARD:
board = std::shared_ptr<Board> (new SynchroniBoard (board_id, params));
break;
case BoardIds::NEUROPAWN_KNIGHT_BOARD:
board =
std::shared_ptr<Board> (new Knight ((int)BoardIds::NEUROPAWN_KNIGHT_BOARD, params));
Expand Down
10 changes: 10 additions & 0 deletions src/board_controller/brainflow_boards.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1160,6 +1160,16 @@ BrainFlowBoards::BrainFlowBoards()
{"num_rows", 4},
{"eeg_channels", {1}}
};
brainflow_boards_json["boards"]["63"]["default"] = {
{"name", "OB3000"},
{"sampling_rate", 500},
{"package_num_channel", 0},
{"timestamp_channel", 25},
{"marker_channel", 26},
{"num_rows", 27},
{"eeg_channels", {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23}},
{"ecg_channels", {24}}
};
}

BrainFlowBoards boards_struct;
6 changes: 5 additions & 1 deletion src/board_controller/synchroni/synchroni_board.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,11 @@ std::string SynchroniBoard::get_lib_name (){
}
#endif
#ifdef __linux__
synclib_name = "libSynchroniLib.so";
#if defined(__arm__) || defined(_M_ARM64) || defined(_M_ARM) || defined(__aarch64__)
synclib_name = "libSynchroniLib_arm64.so";
#else
synclib_name = "libSynchroniLib_x64.so";
#endif
#endif
#ifdef __APPLE__
synclib_name = "libSynchroniLib.dylib";
Expand Down
3 changes: 2 additions & 1 deletion src/utils/inc/brainflow_constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,10 @@ enum class BoardIds : int
OB5000_8_CHANNELS_BOARD = 60,
SYNCHRONI_NEO_8_CHANNELS_BOARD = 61,
SYNCHRONI_UNO_1_CHANNELS_BOARD = 62,
OB3000_24_CHANNELS_BOARD = 63,
// use it to iterate
FIRST = PLAYBACK_FILE_BOARD,
LAST = SYNCHRONI_UNO_1_CHANNELS_BOARD
LAST = OB3000_24_CHANNELS_BOARD

};

Expand Down
37 changes: 23 additions & 14 deletions third_party/synchroni/build.cmake
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
SET (SYNCHRONI_SDK_WRAPPER_NAME "SynchroniLib")
SET (SYNCHRONI_SDK_NAME "sensor")

if (CMAKE_SIZEOF_VOID_P EQUAL 8)
if (APPLE)
SET (SYNCHRONI_SDK_WRAPPER_COMPILED_NAME "libSynchroniLib.dylib")
elseif (UNIX)
SET (SYNCHRONI_SDK_WRAPPER_COMPILED_NAME "libSynchroniLib.so")
if (${CMAKE_SYSTEM_PROCESSOR} MATCHES "aarch64")
set(SYNCHRONI_SDK_WRAPPER_NAME "SynchroniLib_arm64")
SET (SYNCHRONI_SDK_WRAPPER_COMPILED_NAME "libSynchroniLib_arm64.so")
SET (SYNCHRONI_SDK_ARCH "arm64")
SET (SYNCHRONI_SDK_LINK_NAME_LIB "libsensor_arm64.so")
else ()
set(SYNCHRONI_SDK_WRAPPER_NAME "SynchroniLib_x64")
SET (SYNCHRONI_SDK_WRAPPER_COMPILED_NAME "libSynchroniLib_x64.so")
SET (SYNCHRONI_SDK_ARCH "x86_64")
SET (SYNCHRONI_SDK_LINK_NAME_LIB "libsensor_x64.so")
endif ()
else ()
SET (SYNCHRONI_SDK_WRAPPER_COMPILED_NAME "SynchroniLib.dll")
SET (SYNCHRONI_SDK_WRAPPER_COMPILED_NAME_DOT_LIB "SynchroniLib.lib")
Expand Down Expand Up @@ -43,7 +52,7 @@ add_library (
if (APPLE)
target_link_libraries (${SYNCHRONI_SDK_WRAPPER_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/synchroni/lib/mac/sensor.xcframework)
elseif (UNIX)
target_link_libraries (${SYNCHRONI_SDK_WRAPPER_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/synchroni/lib/linux/x86_64/For$<CONFIG>/libsensor.so)
target_link_libraries (${SYNCHRONI_SDK_WRAPPER_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/synchroni/lib/linux/${SYNCHRONI_SDK_ARCH}/For${CMAKE_BUILD_TYPE}/${SYNCHRONI_SDK_LINK_NAME_LIB})
else ()
target_link_libraries (${SYNCHRONI_SDK_WRAPPER_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/synchroni/lib/windows/${SYNCHRONI_SDK_ARCH}/For$<CONFIG>/${SYNCHRONI_SDK_LINK_NAME_DOT_LIB})
endif (APPLE)
Expand Down Expand Up @@ -98,28 +107,28 @@ if (UNIX)
COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_CURRENT_SOURCE_DIR}/compiled/${SYNCHRONI_SDK_WRAPPER_COMPILED_NAME}" "${CMAKE_CURRENT_SOURCE_DIR}/csharp_package/brainflow/brainflow/lib/${SYNCHRONI_SDK_WRAPPER_COMPILED_NAME}"
COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_CURRENT_SOURCE_DIR}/compiled/${SYNCHRONI_SDK_WRAPPER_COMPILED_NAME}" "${CMAKE_CURRENT_SOURCE_DIR}/matlab_package/brainflow/lib/${SYNCHRONI_SDK_WRAPPER_COMPILED_NAME}"
COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_CURRENT_SOURCE_DIR}/compiled/${SYNCHRONI_SDK_WRAPPER_COMPILED_NAME}" "${CMAKE_CURRENT_SOURCE_DIR}/rust_package/brainflow/lib/${SYNCHRONI_SDK_WRAPPER_COMPILED_NAME}"
COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_CURRENT_LIST_DIR}/lib/linux/x86_64/For$<CONFIG>/libsensor.so" "${CMAKE_CURRENT_SOURCE_DIR}/matlab_package/brainflow/lib/libsensor.so"
COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_CURRENT_LIST_DIR}/lib/linux/x86_64/For$<CONFIG>/libsensor.so" "${CMAKE_CURRENT_SOURCE_DIR}/python_package/brainflow/lib/libsensor.so"
COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_CURRENT_LIST_DIR}/lib/linux/x86_64/For$<CONFIG>/libsensor.so" "${CMAKE_CURRENT_SOURCE_DIR}/csharp_package/brainflow/brainflow/lib/libsensor.so"
COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_CURRENT_LIST_DIR}/lib/linux/x86_64/For$<CONFIG>/libsensor.so" "${CMAKE_CURRENT_SOURCE_DIR}/java_package/brainflow/src/main/resources/libsensor.so"
COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_CURRENT_LIST_DIR}/lib/linux/x86_64/For$<CONFIG>/libsensor.so" "${CMAKE_CURRENT_SOURCE_DIR}/julia_package/brainflow/lib/libsensor.so"
COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_CURRENT_LIST_DIR}/lib/linux/x86_64/For$<CONFIG>/libsensor.so" "${CMAKE_CURRENT_SOURCE_DIR}/nodejs_package/brainflow/lib/libsensor.so"
COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_CURRENT_LIST_DIR}/lib/linux/x86_64/For$<CONFIG>/libsensor.so" "${CMAKE_CURRENT_SOURCE_DIR}/rust_package/brainflow/lib/libsensor.so"
COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_CURRENT_LIST_DIR}/lib/linux/${SYNCHRONI_SDK_ARCH}/For${CMAKE_BUILD_TYPE}/${SYNCHRONI_SDK_LINK_NAME_LIB}" "${CMAKE_CURRENT_SOURCE_DIR}/matlab_package/brainflow/lib/${SYNCHRONI_SDK_LINK_NAME_LIB}"
COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_CURRENT_LIST_DIR}/lib/linux/${SYNCHRONI_SDK_ARCH}/For${CMAKE_BUILD_TYPE}/${SYNCHRONI_SDK_LINK_NAME_LIB}" "${CMAKE_CURRENT_SOURCE_DIR}/python_package/brainflow/lib/${SYNCHRONI_SDK_LINK_NAME_LIB}"
COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_CURRENT_LIST_DIR}/lib/linux/${SYNCHRONI_SDK_ARCH}/For${CMAKE_BUILD_TYPE}/${SYNCHRONI_SDK_LINK_NAME_LIB}" "${CMAKE_CURRENT_SOURCE_DIR}/csharp_package/brainflow/brainflow/lib/${SYNCHRONI_SDK_LINK_NAME_LIB}"
COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_CURRENT_LIST_DIR}/lib/linux/${SYNCHRONI_SDK_ARCH}/For${CMAKE_BUILD_TYPE}/${SYNCHRONI_SDK_LINK_NAME_LIB}" "${CMAKE_CURRENT_SOURCE_DIR}/java_package/brainflow/src/main/resources/${SYNCHRONI_SDK_LINK_NAME_LIB}"
COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_CURRENT_LIST_DIR}/lib/linux/${SYNCHRONI_SDK_ARCH}/For${CMAKE_BUILD_TYPE}/${SYNCHRONI_SDK_LINK_NAME_LIB}" "${CMAKE_CURRENT_SOURCE_DIR}/julia_package/brainflow/lib/${SYNCHRONI_SDK_LINK_NAME_LIB}"
COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_CURRENT_LIST_DIR}/lib/linux/${SYNCHRONI_SDK_ARCH}/For${CMAKE_BUILD_TYPE}/${SYNCHRONI_SDK_LINK_NAME_LIB}" "${CMAKE_CURRENT_SOURCE_DIR}/nodejs_package/brainflow/lib/${SYNCHRONI_SDK_LINK_NAME_LIB}"
COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_CURRENT_LIST_DIR}/lib/linux/${SYNCHRONI_SDK_ARCH}/For${CMAKE_BUILD_TYPE}/${SYNCHRONI_SDK_LINK_NAME_LIB}" "${CMAKE_CURRENT_SOURCE_DIR}/rust_package/brainflow/lib/${SYNCHRONI_SDK_LINK_NAME_LIB}"
)
endif (UNIX)

if (MSVC)
if (CMAKE_SIZEOF_VOID_P EQUAL 8)
install (
FILES
${CMAKE_CURRENT_SOURCE_DIR}/compiled/$<CONFIG>/SynchroniLib.dll
${CMAKE_CURRENT_SOURCE_DIR}/compiled/$<CONFIG>/${SYNCHRONI_SDK_WRAPPER_NAME}.dll
${CMAKE_CURRENT_SOURCE_DIR}/third_party/synchroni/lib/windows/${SYNCHRONI_SDK_ARCH}/For$<CONFIG>/${SYNCHRONI_SDK_LINK_NAME_LIB}.dll
DESTINATION lib
)
else (CMAKE_SIZEOF_VOID_P EQUAL 8)
install (
FILES
${CMAKE_CURRENT_SOURCE_DIR}/compiled/$<CONFIG>/SynchroniLib32.dll
${CMAKE_CURRENT_SOURCE_DIR}/compiled/$<CONFIG>/${SYNCHRONI_SDK_WRAPPER_NAME}.dll
${CMAKE_CURRENT_SOURCE_DIR}/third_party/synchroni/lib/windows/${SYNCHRONI_SDK_ARCH}/For$<CONFIG>/${SYNCHRONI_SDK_LINK_NAME_LIB}.dll
DESTINATION lib
)
Expand All @@ -129,8 +138,8 @@ endif (MSVC)
if (UNIX)
install (
FILES
${CMAKE_CURRENT_SOURCE_DIR}/compiled/$<CONFIG>/${SYNCHRONI_SDK_WRAPPER_COMPILED_NAME}
${CMAKE_CURRENT_SOURCE_DIR}/third_party/synchroni/lib/linux/x86_64/For$<CONFIG>/libsensor.so
${CMAKE_CURRENT_SOURCE_DIR}/compiled/${SYNCHRONI_SDK_WRAPPER_COMPILED_NAME}
${CMAKE_CURRENT_SOURCE_DIR}/third_party/synchroni/lib/linux/${SYNCHRONI_SDK_ARCH}/For${CMAKE_BUILD_TYPE}/${SYNCHRONI_SDK_LINK_NAME_LIB}
DESTINATION lib
)
endif(UNIX)
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified third_party/synchroni/lib/windows/Win32/ForDebug/sensor32.dll
Binary file not shown.
Binary file not shown.
Binary file modified third_party/synchroni/lib/windows/Win64/ForDebug/sensor.dll
Binary file not shown.
Binary file modified third_party/synchroni/lib/windows/Win64/ForRelease/sensor.dll
Binary file not shown.
21 changes: 20 additions & 1 deletion third_party/synchroni/src/synchroni_wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include "spdlog/spdlog.h"
#include <memory>
#include <map>

#include <iostream>
// #define ENABLE_LOGGER

using namespace std;
Expand Down Expand Up @@ -562,4 +562,23 @@ BOOL WINAPI DllMain(
}
return TRUE; // Successful DLL_PROCESS_ATTACH.
}
#endif

#ifdef __linux__
//void __attribute__ ((constructor)) my_load (void);
//void __attribute__ ((destructor)) my_unload (void);
//
//// Called when the library is loaded and before dlopen() returns
//void my_load (void)
//{
// printf ("my_load\n");
//}
//
//// Called when the library is unloaded and before dlclose()
//// returns
//void my_unload (void)
//{
// printf ("my_unload\n");
// sensor::SensorController::destory ();
//}
#endif
12 changes: 5 additions & 7 deletions tools/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,6 @@ def prepare_args():
'--no-oymotion', dest='oymotion', action='store_false')
parser.set_defaults(oymotion=False)

parser.add_argument('--synchroni', dest='synchroni', action='store_true')
parser.add_argument('--no-synchroni', dest='synchroni', action='store_false')
parser.set_defaults(synchroni='store_false')

parser.add_argument('--msvc-runtime', type=str, choices=[
'static', 'dynamic'],
help='how to link MSVC runtime', required=False, default='static')
Expand Down Expand Up @@ -186,9 +182,6 @@ def prepare_args():
help='min supported version of osx', required=False, default='10.15')
parser.add_argument('--use-libftdi', action='store_true')

parser.add_argument('--synchroni', dest='synchroni', action='store_true')
parser.add_argument('--no-synchroni', dest='synchroni', action='store_false')
parser.set_defaults(synchroni='store_false')

try:
output = subprocess.check_output(['ninja', '--version'])
Expand All @@ -213,6 +206,11 @@ def prepare_args():
required=False, default=os.path.join(cur_folder, '..', 'installed'))
parser.add_argument('--use-openmp', action='store_true')
parser.add_argument('--onnx', action='store_true')

parser.add_argument('--synchroni', dest='synchroni', action='store_true')
parser.add_argument('--no-synchroni', dest='synchroni', action='store_false')
parser.set_defaults(synchroni='store_false')

parser.add_argument('--warnings-as-errors', action='store_true')
parser.add_argument('--debug', action='store_true')
parser.add_argument('--clear-build-dir', action='store_true')
Expand Down

0 comments on commit a5b1d33

Please sign in to comment.