Skip to content

Commit

Permalink
Merge remote-tracking branch 'openbci/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrey1994 committed Mar 16, 2020
2 parents fa668ff + 114b116 commit ae6e47e
Show file tree
Hide file tree
Showing 7 changed files with 99 additions and 94 deletions.
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ set (CMAKE_CXX_STANDARD 11)
set (CMAKE_VERBOSE_MAKEFILE ON)
set (BRAINFLOW_VERSION 2.1.0)

# dont export sumbols on unix by default
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
set(CMAKE_C_VISIBILITY_PRESET hidden)

set(CMAKE_POSITION_INDEPENDENT_CODE ON)

macro (configure_msvc_runtime)
Expand Down
77 changes: 76 additions & 1 deletion docs/BrainFlowDev.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ CI and tests

If you want to commit to core module of brainflow project please check that all tests are passed, you can enable `Travis CI <https://travis-ci.com/>`_ and `AppVeyour <https://ci.appveyor.com>`_ for your fork of BrainFlow to run tests automatically, or check CI status directly in your PR.

Also you can run integration tests manually for any board even if you dont have real hardware, check :ref:`emulator-label` page for details.
Also you can run integration tests manually for any board even if you dont have real hardware using BrainFlow Emulator.

Pull Requests
--------------
Expand Down Expand Up @@ -93,3 +93,78 @@ Example for Linux(for MacOS it's the same)::
# Run gdb and get backtrace
sudo gdb --args ./brainflow_get_data --board-id 1 --serial-port /dev/ttyACM0 --mac-address e6:73:73:18:09:b1
# In gdb terminal type 'r' to run the program and as soon as error occurs, type 'bt' to see backtrace with exact lines of code and call stack


BrainFlow Emulator
--------------------

BrainFlow Emulator allows you to run all integration tests for all supported boards without real hardware. Our CI uses it for test automation. Also, you can run it on your own PC!

Streaming Board
~~~~~~~~~~~~~~~~~~

Streaming Board emulator works using Python binding for BrainFlow, so **you need to install Python binding first.**

Install emulator package::

cd emulator
python -m pip install -U .

Run tests ::

python emulator\brainflow_emulator\streaming_board_emulator.py python tests\python\brainflow_get_data.py --log --board-id -2 --ip-address 225.1.1.1 --ip-port 6677 --other-info -1

This emulator uses synthetic board as a master board and the IP address and port are hardcoded.

OpenBCI Cyton
~~~~~~~~~~~~~~~

Cyton emulator simulate COM port using:

- `com0com <http://com0com.sourceforge.net/>`_ for Windows
- pty for Linux and MacOS

You should pass test command line directly to cyton_linux.py or to cyton_windows.py. The script will add the port automatically to provided command line and will start an application.


Install emulator package::

cd emulator
python -m pip install -U .

Run tests for Linux\MacOS and Windows (port argument will be added by Emulator!) ::

python brainflow_emulator/cyton_linux.py python ../tests/python/brainflow_get_data.py --log --board-id 0 --serial-port
python brainflow_emulator\cyton_windows.py python ..\tests\python\brainflow_get_data.py --log --board-id 0 --serial-port


OpenBCI NovaXR
~~~~~~~~~~~~~~~~

NovaXR emulator creates socket server and streams data to BrainFlow like it's a real board, but with much lower sampling rate.

Install emulator package::

cd emulator
python -m pip install -U .

Run tests::

python brainflow_emulator/novaxr_udp.py python ../tests/python/brainflow_get_data.py --log --ip-address 127.0.0.1 --board-id 3

OpenBCI Wifi Shield based boards
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Wifi shield emulator starts http server to read commands and creates client socket to stream data.

Install emulator package::

cd emulator
python -m pip install -U .

Run tests for Ganglion, Cyton and Daisy with Wifi Shield::

python brainflow_emulator/wifi_shield_emulator.py python ../tests/python/brainflow_get_data.py --log --ip-address 127.0.0.1 --board-id 4 --ip-protocol 2 --ip-port 17982
python brainflow_emulator/wifi_shield_emulator.py python ../tests/python/brainflow_get_data.py --log --ip-address 127.0.0.1 --board-id 5 --ip-protocol 2 --ip-port 17982
python brainflow_emulator/wifi_shield_emulator.py python ../tests/python/brainflow_get_data.py --log --ip-address 127.0.0.1 --board-id 6 --ip-protocol 2 --ip-port 17982

75 changes: 0 additions & 75 deletions docs/BrainFlowEmulator.rst

This file was deleted.

1 change: 0 additions & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ It provides a **uniform data acquisition API for all supported boards**, it mean
DataFormatDesc
Examples
BrainFlowDev
BrainFlowEmulator
AskHelp
License

Expand Down
2 changes: 1 addition & 1 deletion src/board_controller/inc/board_controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#define SHARED_EXPORT __declspec(dllexport)
#define CALLING_CONVENTION __cdecl
#else
#define SHARED_EXPORT
#define SHARED_EXPORT __attribute__((visibility("default")))
#define CALLING_CONVENTION
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/board_controller/inc/board_info_getter.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#define SHARED_EXPORT __declspec(dllexport)
#define CALLING_CONVENTION __cdecl
#else
#define SHARED_EXPORT
#define SHARED_EXPORT __attribute__((visibility("default")))
#define CALLING_CONVENTION
#endif

Expand Down
32 changes: 17 additions & 15 deletions src/data_handler/inc/data_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

#ifdef _WIN32
#define SHARED_EXPORT __declspec(dllexport)
#define CALLING_CONVENTION __cdecl
#else
#define SHARED_EXPORT
#define SHARED_EXPORT __attribute__((visibility("default")))
#define CALLING_CONVENTION
#endif

#include "brainflow_constants.h"
Expand Down Expand Up @@ -33,40 +35,40 @@ extern "C"
#endif
// signal processing methods
// ripple param is used only for chebyshev filter
SHARED_EXPORT int perform_lowpass (double *data, int data_len, int sampling_rate, double cutoff,
SHARED_EXPORT int CALLING_CONVENTION perform_lowpass (double *data, int data_len, int sampling_rate, double cutoff,
int order, int filter_type, double ripple);
SHARED_EXPORT int perform_highpass (double *data, int data_len, int sampling_rate,
SHARED_EXPORT int CALLING_CONVENTION perform_highpass (double *data, int data_len, int sampling_rate,
double cutoff, int order, int filter_type, double ripple);
SHARED_EXPORT int perform_bandpass (double *data, int data_len, int sampling_rate,
SHARED_EXPORT int CALLING_CONVENTION perform_bandpass (double *data, int data_len, int sampling_rate,
double center_freq, double band_width, int order, int filter_type, double ripple);
SHARED_EXPORT int perform_bandstop (double *data, int data_len, int sampling_rate,
SHARED_EXPORT int CALLING_CONVENTION perform_bandstop (double *data, int data_len, int sampling_rate,
double center_freq, double band_width, int order, int filter_type, double ripple);

SHARED_EXPORT int perform_rolling_filter (
SHARED_EXPORT int CALLING_CONVENTION perform_rolling_filter (
double *data, int data_len, int period, int agg_operation);

SHARED_EXPORT int perform_downsampling (
SHARED_EXPORT int CALLING_CONVENTION perform_downsampling (
double *data, int data_len, int period, int agg_operation, double *output_data);

SHARED_EXPORT int perform_wavelet_transform (double *data, int data_len, char *wavelet,
SHARED_EXPORT int CALLING_CONVENTION perform_wavelet_transform (double *data, int data_len, char *wavelet,
int decomposition_level, double *output_data, int *decomposition_lengths);
SHARED_EXPORT int perform_inverse_wavelet_transform (double *wavelet_coeffs,
SHARED_EXPORT int CALLING_CONVENTION perform_inverse_wavelet_transform (double *wavelet_coeffs,
int original_data_len, char *wavelet, int decomposition_level, int *decomposition_lengths,
double *output_data);
SHARED_EXPORT int perform_wavelet_denoising (
SHARED_EXPORT int CALLING_CONVENTION perform_wavelet_denoising (
double *data, int data_len, char *wavelet, int decomposition_level);
SHARED_EXPORT int perform_fft (
SHARED_EXPORT int CALLING_CONVENTION perform_fft (
double *data, int data_len, double *output_re, double *output_im);
SHARED_EXPORT int perform_ifft (
SHARED_EXPORT int CALLING_CONVENTION perform_ifft (
double *input_re, double *input_im, int data_len, double *restored_data);


// file operations
SHARED_EXPORT int write_file (
SHARED_EXPORT int CALLING_CONVENTION write_file (
double *data, int num_rows, int num_cols, char *file_name, char *file_mode);
SHARED_EXPORT int read_file (
SHARED_EXPORT int CALLING_CONVENTION read_file (
double *data, int *num_rows, int *num_cols, char *file_name, int num_elements);
SHARED_EXPORT int get_num_elements_in_file (
SHARED_EXPORT int CALLING_CONVENTION get_num_elements_in_file (
char *file_name, int *num_elements); // its an internal method for bindings its not
// available via high level api
#ifdef __cplusplus
Expand Down

0 comments on commit ae6e47e

Please sign in to comment.