Skip to content

Commit 6340004

Browse files
committed
2 parents 359e3d5 + a2fde4c commit 6340004

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+513
-15
lines changed

.github/workflows/deploy.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ jobs:
4848
run: |
4949
mkdir %GITHUB_WORKSPACE%\build64
5050
cd %GITHUB_WORKSPACE%\build64
51-
cmake -DWARNINGS_AS_ERRORS=ON -G "Visual Studio 16 2019" -A x64 -DCMAKE_SYSTEM_VERSION=8.1 -DCMAKE_INSTALL_PREFIX=..\installed64\ ..
51+
cmake -DBRAINFLOW_VERSION=%GITHUB_SHA% -DWARNINGS_AS_ERRORS=ON -G "Visual Studio 16 2019" -A x64 -DCMAKE_SYSTEM_VERSION=8.1 -DCMAKE_INSTALL_PREFIX=..\installed64\ ..
5252
cmake --build . --target install --config Release -j 2 --parallel 2
5353
shell: cmd
5454
# Download all artifacts from AWS
@@ -199,7 +199,6 @@ jobs:
199199
cd $env:GITHUB_WORKSPACE\python-package
200200
twine upload --skip-existing dist/*.whl --user Andrey1994 --password $env:PYPI_PASSWORD
201201
cd $env:GITHUB_WORKSPACE\rust-package\brainflow
202-
# cargo publish --allow-dirty
203202
env:
204203
CARGO_TOKEN: ${{ secrets.CARGO_TOKEN }}
205204
PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }}

.github/workflows/run_unix.yml

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ jobs:
1616
# compile and prepare env
1717
- name: Clone Repository
1818
uses: actions/checkout@v2
19+
- name: Set Version
20+
id: version
21+
run: if [ $GITHUB_REF_TYPE == "tag" ]; then echo "::set-output name=version::$GITHUB_REF_NAME"; else echo "::set-output name=version::$GITHUB_SHA"; fi
22+
- name: Check Version
23+
run: echo ${{ steps.version.outputs.version }}
1924
- name: Install Python 3.7
2025
uses: actions/setup-python@v2
2126
with:
@@ -59,23 +64,29 @@ jobs:
5964
run: |
6065
mkdir $GITHUB_WORKSPACE/build
6166
cd $GITHUB_WORKSPACE/build
62-
cmake -G Ninja -DBUILD_BLUETOOTH=ON -DWARNINGS_AS_ERRORS=ON -DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" -DCMAKE_OSX_DEPLOYMENT_TARGET=10.13 -DCMAKE_INSTALL_PREFIX=$GITHUB_WORKSPACE/installed -DCMAKE_BUILD_TYPE=Release ..
67+
cmake -G Ninja -DBRAINFLOW_VERSION=$BRAINFLOW_VERSION -DBUILD_BLUETOOTH=ON -DWARNINGS_AS_ERRORS=ON -DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" -DCMAKE_OSX_DEPLOYMENT_TARGET=10.13 -DCMAKE_INSTALL_PREFIX=$GITHUB_WORKSPACE/installed -DCMAKE_BUILD_TYPE=Release ..
6368
ninja
6469
ninja install
70+
env:
71+
BRAINFLOW_VERSION: ${{ steps.version.outputs.version }}
6572
- name: Compile BrainFlow Ubuntu
6673
if: (matrix.os == 'ubuntu-latest')
6774
run: |
6875
mkdir $GITHUB_WORKSPACE/build
6976
cd $GITHUB_WORKSPACE/build
70-
cmake -DBUILD_BLUETOOTH=ON -DWARNINGS_AS_ERRORS=ON -DCMAKE_INSTALL_PREFIX=$GITHUB_WORKSPACE/installed -DCMAKE_BUILD_TYPE=Release ..
77+
cmake -DBRAINFLOW_VERSION=$BRAINFLOW_VERSION -DBUILD_BLUETOOTH=ON -DWARNINGS_AS_ERRORS=ON -DCMAKE_INSTALL_PREFIX=$GITHUB_WORKSPACE/installed -DCMAKE_BUILD_TYPE=Release ..
7178
make
7279
make install
80+
env:
81+
BRAINFLOW_VERSION: ${{ steps.version.outputs.version }}
7382
- name: Compile BrainFlow in ManyLinux
7483
# bindings in production have to use libraries compiled inside this image!
7584
if: (matrix.os == 'ubuntu-latest')
7685
run: |
7786
docker pull dockcross/manylinux2014-x64:20210708-94745ff
78-
docker run -e GITHUB_WORKSPACE=$GITHUB_WORKSPACE -v $GITHUB_WORKSPACE:$GITHUB_WORKSPACE dockcross/manylinux2014-x64:20210708-94745ff /bin/bash -c "yum install -y bluez-libs-devel dbus-devel && /opt/python/cp36-cp36m/bin/pip3.6 install cmake==3.13.3 && cd $GITHUB_WORKSPACE && mkdir build_docker && cd build_docker && cmake -DBUILD_BLE=ON -DBUILD_BLUETOOTH=ON -DCMAKE_INSTALL_PREFIX=$GITHUB_WORKSPACE/installed_docker -DCMAKE_BUILD_TYPE=Release .. && make && make install"
87+
docker run -e BRAINFLOW_VERSION=$BRAINFLOW_VERSION -e GITHUB_WORKSPACE=$GITHUB_WORKSPACE -v $GITHUB_WORKSPACE:$GITHUB_WORKSPACE dockcross/manylinux2014-x64:20210708-94745ff /bin/bash -c "yum install -y bluez-libs-devel dbus-devel && /opt/python/cp36-cp36m/bin/pip3.6 install cmake==3.13.3 && cd $GITHUB_WORKSPACE && mkdir build_docker && cd build_docker && cmake -DBRAINFLOW_VERSION=$BRAINFLOW_VERSION -DBUILD_BLE=ON -DBUILD_BLUETOOTH=ON -DCMAKE_INSTALL_PREFIX=$GITHUB_WORKSPACE/installed_docker -DCMAKE_BUILD_TYPE=Release .. && make && make install"
88+
env:
89+
BRAINFLOW_VERSION: ${{ steps.version.outputs.version }}
7990
- name: Setup Python Package
8091
run: |
8192
cd $GITHUB_WORKSPACE/python-package

.github/workflows/run_windows.yml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ jobs:
1717
uses: actions/checkout@v2
1818
- name: Add msbuild to PATH
1919
uses: microsoft/[email protected]
20+
- name: Set Version
21+
id: version
22+
run: if ("tag" -eq $Env:GITHUB_REF_TYPE) { echo "::set-output name=version::$Env:GITHUB_REF_NAME" } else { echo "::set-output name=version::$Env:GITHUB_SHA" }
23+
- name: Check Version
24+
run: echo ${{ steps.version.outputs.version }}
2025
- name: Set Path
2126
run: |
2227
echo %GITHUB_WORKSPACE%\tools>>%GITHUB_PATH%
@@ -36,15 +41,19 @@ jobs:
3641
run: |
3742
mkdir %GITHUB_WORKSPACE%\build32
3843
cd %GITHUB_WORKSPACE%\build32
39-
cmake -DBUILD_OYMOTION_SDK=ON -DBUILD_BLUETOOTH=ON -DWARNINGS_AS_ERRORS=ON -G "Visual Studio 16 2019" -A Win32 -DCMAKE_SYSTEM_VERSION=8.1 -DCMAKE_INSTALL_PREFIX=..\installed32\ ..
44+
cmake -DBRAINFLOW_VERSION=%BRAINFLOW_VERSION% -DBUILD_OYMOTION_SDK=ON -DBUILD_BLUETOOTH=ON -DWARNINGS_AS_ERRORS=ON -G "Visual Studio 16 2019" -A Win32 -DCMAKE_SYSTEM_VERSION=8.1 -DCMAKE_INSTALL_PREFIX=..\installed32\ ..
4045
cmake --build . --target install --config Release -j 2 --parallel 2
46+
env:
47+
BRAINFLOW_VERSION: ${{ steps.version.outputs.version }}
4148
shell: cmd
4249
- name: Compile x64
4350
run: |
4451
mkdir %GITHUB_WORKSPACE%\build64
4552
cd %GITHUB_WORKSPACE%\build64
46-
cmake -DBUILD_OYMOTION_SDK=ON -DBUILD_BLUETOOTH=ON -DWARNINGS_AS_ERRORS=ON -G "Visual Studio 16 2019" -A x64 -DCMAKE_SYSTEM_VERSION=8.1 -DCMAKE_INSTALL_PREFIX=..\installed64\ ..
53+
cmake -DBRAINFLOW_VERSION=%BRAINFLOW_VERSION% -DBUILD_OYMOTION_SDK=ON -DBUILD_BLUETOOTH=ON -DWARNINGS_AS_ERRORS=ON -G "Visual Studio 16 2019" -A x64 -DCMAKE_SYSTEM_VERSION=8.1 -DCMAKE_INSTALL_PREFIX=..\installed64\ ..
4754
cmake --build . --target install --config Release -j 2 --parallel 2
55+
env:
56+
BRAINFLOW_VERSION: ${{ steps.version.outputs.version }}
4857
shell: cmd
4958
# need to build SimpleBLE outside from BrainFlow because they have different Windows System Versions
5059
- name: Compile SimpleBLE x32

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ project (brainflow)
33

44
SET (CMAKE_CXX_STANDARD 11)
55
SET (CMAKE_VERBOSE_MAKEFILE ON)
6-
SET (BRAINFLOW_VERSION 3.7.3)
6+
SET (BRAINFLOW_VERSION "0.0.1" CACHE STRING "BrainFlow Version")
77

88
SET (CMAKE_CXX_VISIBILITY_PRESET hidden)
99
SET (CMAKE_C_VISIBILITY_PRESET hidden)

cpp-package/src/board_shim.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -517,3 +517,17 @@ std::vector<int> BoardShim::get_resistance_channels (int board_id)
517517
}
518518
return std::vector<int> (channels, channels + len);
519519
}
520+
521+
std::string BoardShim::get_version ()
522+
{
523+
char version[64];
524+
int string_len = 0;
525+
int res = ::get_version_board_controller (version, &string_len, 64);
526+
if (res != (int)BrainFlowExitCodes::STATUS_OK)
527+
{
528+
throw BrainFlowException ("failed to get board info", res);
529+
}
530+
std::string verion_str (version, string_len);
531+
532+
return verion_str;
533+
}

cpp-package/src/data_filter.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,3 +428,17 @@ double DataFilter::calc_stddev (double *data, int start_pos, int end_pos)
428428
}
429429
return output;
430430
}
431+
432+
std::string DataFilter::get_version ()
433+
{
434+
char version[64];
435+
int string_len = 0;
436+
int res = ::get_version_data_handler (version, &string_len, 64);
437+
if (res != (int)BrainFlowExitCodes::STATUS_OK)
438+
{
439+
throw BrainFlowException ("failed to get board info", res);
440+
}
441+
std::string verion_str (version, string_len);
442+
443+
return verion_str;
444+
}

cpp-package/src/inc/board_shim.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,8 @@ class BoardShim
171171
static std::vector<int> get_resistance_channels (int board_id);
172172
/// release all currently prepared session
173173
static void release_all_sessions ();
174+
/// get brainflow version
175+
static std::string get_version ();
174176

175177
int board_id;
176178

cpp-package/src/inc/data_filter.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,4 +151,7 @@ class DataFilter
151151
static BrainFlowArray<double, 2> read_file (std::string file_name);
152152
/// calc stddev
153153
static double calc_stddev (double *data, int start_pos, int end_pos);
154+
155+
/// get brainflow version
156+
static std::string get_version ();
154157
};

cpp-package/src/inc/ml_model.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ class MLModel
3535
static void set_log_level (int log_level);
3636
/// release all currently prepared classifiers
3737
static void release_all ();
38+
/// get brainflow version
39+
static std::string get_version ();
3840

3941
/// initialize classifier, should be called first
4042
void prepare ();

cpp-package/src/ml_model.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,3 +96,17 @@ void MLModel::enable_dev_ml_logger ()
9696
{
9797
MLModel::set_log_level ((int)LogLevels::LEVEL_TRACE);
9898
}
99+
100+
std::string MLModel::get_version ()
101+
{
102+
char version[64];
103+
int string_len = 0;
104+
int res = ::get_version_ml_module (version, &string_len, 64);
105+
if (res != (int)BrainFlowExitCodes::STATUS_OK)
106+
{
107+
throw BrainFlowException ("failed to get board info", res);
108+
}
109+
std::string verion_str (version, string_len);
110+
111+
return verion_str;
112+
}

csharp-package/brainflow/brainflow/board_controller_library.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,8 @@ public static class BoardControllerLibrary64
170170
public static extern int get_board_descr (int board_id, byte[] board_descr, int[] len);
171171
[DllImport ("BoardController.dll", SetLastError = true, CallingConvention = CallingConvention.Cdecl)]
172172
public static extern int release_all_sessions ();
173+
[DllImport ("BoardController.dll", SetLastError = true, CallingConvention = CallingConvention.Cdecl)]
174+
public static extern int get_version_board_controller (byte[] version, int[] len, int max_len);
173175
}
174176

175177
public static class BoardControllerLibrary32
@@ -246,6 +248,8 @@ public static class BoardControllerLibrary32
246248
public static extern int get_board_descr (int board_id, byte[] board_descr, int[] len);
247249
[DllImport ("BoardController32.dll", SetLastError = true, CallingConvention = CallingConvention.Cdecl)]
248250
public static extern int release_all_sessions ();
251+
[DllImport ("BoardController32.dll", SetLastError = true, CallingConvention = CallingConvention.Cdecl)]
252+
public static extern int get_version_board_controller (byte[] version, int[] len, int max_len);
249253
}
250254

251255
public static class BoardControllerLibraryLinux
@@ -322,6 +326,8 @@ public static class BoardControllerLibraryLinux
322326
public static extern int get_board_descr (int board_id, byte[] board_descr, int[] len);
323327
[DllImport ("libBoardController.so", SetLastError = true, CallingConvention = CallingConvention.Cdecl)]
324328
public static extern int release_all_sessions ();
329+
[DllImport ("libBoardController.so", SetLastError = true, CallingConvention = CallingConvention.Cdecl)]
330+
public static extern int get_version_board_controller (byte[] version, int[] len, int max_len);
325331
}
326332

327333
public static class BoardControllerLibraryMac
@@ -398,6 +404,8 @@ public static class BoardControllerLibraryMac
398404
public static extern int get_board_descr (int board_id, byte[] board_descr, int[] len);
399405
[DllImport ("libBoardController.dylib", SetLastError = true, CallingConvention = CallingConvention.Cdecl)]
400406
public static extern int release_all_sessions ();
407+
[DllImport ("libBoardController.dylib", SetLastError = true, CallingConvention = CallingConvention.Cdecl)]
408+
public static extern int get_version_board_controller (byte[] version, int[] len, int max_len);
401409
}
402410

403411
public static class BoardControllerLibrary
@@ -777,6 +785,23 @@ public static int get_device_name (int board_id, byte[] name, int[] len)
777785
return (int)CustomExitCodes.GENERAL_ERROR;
778786
}
779787

788+
public static int get_version_board_controller (byte[] version, int[] len, int max_len)
789+
{
790+
switch (PlatformHelper.get_library_environment())
791+
{
792+
case LibraryEnvironment.x64:
793+
return BoardControllerLibrary64.get_version_board_controller (version, len, max_len);
794+
case LibraryEnvironment.x86:
795+
return BoardControllerLibrary32.get_version_board_controller (version, len, max_len);
796+
case LibraryEnvironment.Linux:
797+
return BoardControllerLibraryLinux.get_version_board_controller (version, len, max_len);
798+
case LibraryEnvironment.MacOS:
799+
return BoardControllerLibraryMac.get_version_board_controller (version, len, max_len);
800+
}
801+
802+
return (int)CustomExitCodes.GENERAL_ERROR;
803+
}
804+
780805
public static int get_eeg_channels (int board_id, int[] channels, int[] len)
781806
{
782807
switch (PlatformHelper.get_library_environment ())

csharp-package/brainflow/brainflow/board_shim.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,24 @@ public static string get_device_name (int board_id)
216216
return name;
217217
}
218218

219+
/// <summary>
220+
/// get version
221+
/// </summary>
222+
/// <returns>version</returns>
223+
/// <exception cref="BrainFlowException"></exception>
224+
public static string get_version ()
225+
{
226+
int[] len = new int[1];
227+
byte[] str = new byte[64];
228+
int res = BoardControllerLibrary.get_version_board_controller (str, len, 64);
229+
if (res != (int)CustomExitCodes.STATUS_OK)
230+
{
231+
throw new BrainFlowException (res);
232+
}
233+
string version = System.Text.Encoding.UTF8.GetString (str, 0, len[0]);
234+
return version;
235+
}
236+
219237
/// <summary>
220238
/// get row indices of EEG channels for this board, for some board we can not split EMG\EEG\.. data and return the same array for all of them
221239
/// </summary>

csharp-package/brainflow/brainflow/data_filter.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -617,5 +617,23 @@ public static double get_band_power (Tuple<double[], double[]> psd, double start
617617
}
618618
return band_power[0];
619619
}
620+
621+
/// <summary>
622+
/// get version
623+
/// </summary>
624+
/// <returns>version</returns>
625+
/// <exception cref="BrainFlowException"></exception>
626+
public static string get_version ()
627+
{
628+
int[] len = new int[1];
629+
byte[] str = new byte[64];
630+
int res = DataHandlerLibrary.get_version_data_handler (str, len, 64);
631+
if (res != (int)CustomExitCodes.STATUS_OK)
632+
{
633+
throw new BrainFlowException (res);
634+
}
635+
string version = System.Text.Encoding.UTF8.GetString (str, 0, len[0]);
636+
return version;
637+
}
620638
}
621639
}

csharp-package/brainflow/brainflow/data_handler_library.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ public static extern int perform_inverse_wavelet_transform (double[] wavelet_coe
9292
public static extern int get_avg_band_powers (double[] data, int rows, int cols, int sampling_rate, int apply_filters, double[] avgs, double[] stddevs);
9393
[DllImport ("DataHandler.dll", SetLastError = true, CallingConvention = CallingConvention.Cdecl)]
9494
public static extern int calc_stddev (double[] data, int start_pos, int end_pos, double[] output);
95+
[DllImport("DataHandler.dll", SetLastError = true, CallingConvention = CallingConvention.Cdecl)]
96+
public static extern int get_version_data_handler (byte[] version, int[] len, int max_len);
9597
}
9698

9799
class DataHandlerLibrary32
@@ -149,6 +151,8 @@ public static extern int perform_inverse_wavelet_transform (double[] wavelet_coe
149151
public static extern int remove_environmental_noise (double[] data, int len, int sampling_rate, int noise_type);
150152
[DllImport ("DataHandler32.dll", SetLastError = true, CallingConvention = CallingConvention.Cdecl)]
151153
public static extern int calc_stddev (double[] data, int start_pos, int end_pos, double[] output);
154+
[DllImport ("DataHandler32.dll", SetLastError = true, CallingConvention = CallingConvention.Cdecl)]
155+
public static extern int get_version_data_handler (byte[] version, int[] len, int max_len);
152156
}
153157

154158
class DataHandlerLibraryLinux
@@ -206,6 +210,8 @@ public static extern int perform_inverse_wavelet_transform (double[] wavelet_coe
206210
public static extern int remove_environmental_noise (double[] data, int len, int sampling_rate, int noise_type);
207211
[DllImport ("libDataHandler.so", SetLastError = true, CallingConvention = CallingConvention.Cdecl)]
208212
public static extern int calc_stddev (double[] data, int start_pos, int end_pos, double[] output);
213+
[DllImport ("libDataHandler.so", SetLastError = true, CallingConvention = CallingConvention.Cdecl)]
214+
public static extern int get_version_data_handler (byte[] version, int[] len, int max_len);
209215
}
210216

211217
class DataHandlerLibraryMac
@@ -263,6 +269,8 @@ public static extern int perform_inverse_wavelet_transform (double[] wavelet_coe
263269
public static extern int remove_environmental_noise (double[] data, int len, int sampling_rate, int noise_type);
264270
[DllImport ("libDataHandler.dylib", SetLastError = true, CallingConvention = CallingConvention.Cdecl)]
265271
public static extern int calc_stddev (double[] data, int start_pos, int end_pos, double[] output);
272+
[DllImport ("libDataHandler.dylib", SetLastError = true, CallingConvention = CallingConvention.Cdecl)]
273+
public static extern int get_version_data_handler (byte[] version, int[] len, int max_len);
266274
}
267275

268276
class DataHandlerLibrary
@@ -711,5 +719,22 @@ public static int calc_stddev (double[] data, int start_pos, int end_pos, double
711719

712720
return (int)CustomExitCodes.GENERAL_ERROR;
713721
}
722+
723+
public static int get_version_data_handler (byte[] version, int[] len, int max_len)
724+
{
725+
switch (PlatformHelper.get_library_environment())
726+
{
727+
case LibraryEnvironment.x64:
728+
return DataHandlerLibrary64.get_version_data_handler (version, len, max_len);
729+
case LibraryEnvironment.x86:
730+
return DataHandlerLibrary32.get_version_data_handler (version, len, max_len);
731+
case LibraryEnvironment.Linux:
732+
return DataHandlerLibraryLinux.get_version_data_handler (version, len, max_len);
733+
case LibraryEnvironment.MacOS:
734+
return DataHandlerLibraryMac.get_version_data_handler (version, len, max_len);
735+
}
736+
737+
return (int)CustomExitCodes.GENERAL_ERROR;
738+
}
714739
}
715740
}

csharp-package/brainflow/brainflow/ml_model.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,5 +121,23 @@ public double predict (double[] data)
121121
return val[0];
122122
}
123123

124+
/// <summary>
125+
/// get version
126+
/// </summary>
127+
/// <returns>version</returns>
128+
/// <exception cref="BrainFlowException"></exception>
129+
public static string get_version ()
130+
{
131+
int[] len = new int[1];
132+
byte[] str = new byte[64];
133+
int res = MLModuleLibrary.get_version_ml_module (str, len, 64);
134+
if (res != (int)CustomExitCodes.STATUS_OK)
135+
{
136+
throw new BrainFlowException (res);
137+
}
138+
string version = System.Text.Encoding.UTF8.GetString (str, 0, len[0]);
139+
return version;
140+
}
141+
124142
}
125143
}

0 commit comments

Comments
 (0)