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 Jan 27, 2020
2 parents a2d920e + edbff40 commit df123cf
Show file tree
Hide file tree
Showing 8 changed files with 546 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -334,12 +334,17 @@ ASALocalRun/
.raw
.txt

#Environment file
.env
.vscode/

build*
installed*
compiled/
python/flowcat.egg-info/
.Rproj.user

# Build files
java-package/brainflow/target
java-package/brainflow/.classpath
java-package/brainflow/.project
Expand Down
13 changes: 12 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ addons:
# - r-base
- libxml2-dev
- valgrind
- cppcheck
# R disabled. It's taking up too much time in CI
# homebrew:
# packages:
Expand Down Expand Up @@ -77,6 +78,10 @@ before_script:
fi

script:
# static analyzer
- if [ "$TRAVIS_OS_NAME" = "linux" ]; then
cd $TRAVIS_BUILD_DIR && cppcheck --xml --xml-version=2 --force src cpp-package third_party 2>cppcheck_res.xml && cppcheck-htmlreport --title=BrainFlow --file=cppcheck_res.xml --report-dir=report ;
fi
# tests for boards
# tests for cyton
- sudo -H python3 $TRAVIS_BUILD_DIR/emulator/brainflow_emulator/cyton_linux.py python3 $TRAVIS_BUILD_DIR/tests/python/brainflow_get_data.py --log --board-id 0 --serial-port
Expand Down Expand Up @@ -110,6 +115,9 @@ script:
- if [ `which valgrind` ]; then
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$TRAVIS_BUILD_DIR/installed/lib python3 $TRAVIS_BUILD_DIR/emulator/brainflow_emulator/novaxr_udp.py valgrind --error-exitcode=1 --leak-check=full $TRAVIS_BUILD_DIR/tests/cpp/get_data_demo/build/brainflow_get_data --board-id 3 --ip-address 127.0.0.1 ;
fi
- if [ `which valgrind` ]; then
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$TRAVIS_BUILD_DIR/installed/lib python3 $TRAVIS_BUILD_DIR/emulator/brainflow_emulator/novaxr_udp.py valgrind --error-exitcode=1 --leak-check=full $TRAVIS_BUILD_DIR/tests/cpp/get_data_demo/build/brainflow_get_data_twice --board-id 3 --ip-address 127.0.0.1 ;
fi
# tests for wifi shield, fails on macos due to an issue in emulator
- if [ "$TRAVIS_OS_NAME" = "linux" ]; then
sudo -H python3 $TRAVIS_BUILD_DIR/emulator/brainflow_emulator/wifi_shield_emulator.py python3 $TRAVIS_BUILD_DIR/tests/python/brainflow_get_data.py --log --board-id 4 --ip-address 127.0.0.1 --ip-port 17982 ;
Expand Down Expand Up @@ -164,7 +172,6 @@ script:
- cd $TRAVIS_BUILD_DIR/java-package/brainflow && mvn exec:java -Dexec.mainClass="brainflow.examples.SignalFiltering"
- cd $TRAVIS_BUILD_DIR/java-package/brainflow && mvn exec:java -Dexec.mainClass="brainflow.examples.Transforms"


# after_success:
# - sudo -H pip3 install awscli
# # push libraries from docker!
Expand All @@ -174,6 +181,10 @@ script:
# - if [ "$TRAVIS_OS_NAME" = "osx" ]; then
# aws s3 cp $TRAVIS_BUILD_DIR/installed/lib/ s3://brainflow/$TRAVIS_COMMIT/$TRAVIS_OS_NAME --recursive ;
# fi
# # push results of static analyzer
# - if [ "$TRAVIS_OS_NAME" = "linux" ]; then
# aws s3 cp $TRAVIS_BUILD_DIR/report s3://brainflow-artifacts/$TRAVIS_COMMIT/report --recursive ;
# fi
# # notify that everything is ok
# - echo success > ${TRAVIS_OS_NAME}_success && aws s3 cp ${TRAVIS_OS_NAME}_success s3://brainflow/$TRAVIS_COMMIT/

Expand Down
31 changes: 31 additions & 0 deletions docs/BrainFlowDev.rst
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,34 @@ Install requirements::
Build docs::

make html

Debug BrainFlow's errors
---------------------------

Since bindings just call methods from dynamic libraries, more likely errors occur in C++ code, it means that you need to use C++ debuger like gdb. If there is an error in binding, it should be simple to figure out and resolve the issue using language specific tools.

Steps to get more information about errors in C++ code:

- build BrainFlow's core module and C++ binding in debug mode. In files like tools/build_linux.sh default config is Release, so you need to change it to Debug
- reproduce your issue using C++ binding
- run it with debuger and memory checker

Example for Linux(for MacOS it's the same)::

vim tools/build_linux.sh
# Change build type to Debug
bash tools/build_linux.sh
# Create a test to reproduce your issue in C++, here we will use get_data_demo
cd tests/cpp/get_data_demo
mkdir build
cd build
cmake -DCMAKE_PREFIX_PATH=TYPE_FULL_PATH_TO_BRAINFLOW_INSTALLED_FOLDER ..
# e.g. cmake -DCMAKE_PREFIX_PATH=/home/andrey/brainflow/installed_linux -DCMAKE_BUILD_TYPE=Debug ..
make
# Run Valgrind to check memory errors
# Here we use command line for Ganglion
sudo valgrind --error-exitcode=1 --leak-check=full ./brainflow_get_data --board-id 1 --serial-port /dev/ttyACM0 --mac-address e6:73:73:18:09:b1
# Valgrind will print Error Summary and exact line numbers
# 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
15 changes: 14 additions & 1 deletion docs/Examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,19 @@ C# Denoising
C++
-----

.. compound::

To compile examples below for Linux or MacOS run: ::

cd tests/cpp/get_data_demo
mkdir build
cd build
cmake -DCMAKE_PREFIX_PATH=TYPE_FULL_PATH_TO_BRAINFLOW_INSTALLED_FOLDER ..
# e.g. cmake -DCMAKE_PREFIX_PATH=/home/andrey/brainflow/installed_linux ..
make

For Windows it's almost the same.

**Make sure that compiled dynamic libraries exist in search path before running an executable by doing one of the following:**

- for Linux and MacOS add them to LD_LIBRARY_PATH env variable
Expand All @@ -151,7 +164,7 @@ C++
CMake File Example
~~~~~~~~~~~~~~~~~~~~~

.. literalinclude:: ../tests/cpp/get_data_demo/CMakeLists.txt
.. literalinclude:: ../tests/cpp/signal_processing_demo/CMakeLists.txt
:language: none

C++ Read Data from a Board
Expand Down
8 changes: 6 additions & 2 deletions docs/SupportedBoards.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ To create an instance of BoardShim class for your board check required inputs in

"Streaming Board", "BoardIds.STREAMING_BOARD (-2)", "-", "-", "multicast IP address", "port", "-", "Board Id of master board"
"Synthetic Board", "BoardIds.SYNTHETIC_BOARD (-1)", "-", "-", "-", "-", "-", "-"
"Cyton", "BoardIds.CYTON_BOARD (0)", "dongle serial port(COM3, /dev/ttyUSB0...)", "-", "-", "-", "-", "-"
"Cyton", "BoardIds.CYTON_BOARD (0)", "dongle serial port(COM3, /dev/ttyUSB0, /dev/cu.usbserial-xxxxxx...)", "-", "-", "-", "-", "-"
"Ganglion", "BoardIds.GANGLION_BOARD (1)", "dongle serial port(COM3, /dev/ttyUSB0...)", "Optional: Ganglion's MAC address", "-", "-", "-", "-"
"Cyton Daisy", "BoardIds.CYTON_DAISY_BOARD (2)", "dongle serial port(COM3, /dev/ttyUSB0...)", "-", "-", "-", "-", "-"
"Cyton Daisy", "BoardIds.CYTON_DAISY_BOARD (2)", "dongle serial port(COM3, /dev/ttyUSB0, /dev/cu.usbserial-xxxxxx...)", "-", "-", "-", "-", "-"
"Ganglion Wifi", "BoardIds.GANGLION_WIFI_BOARD (4)", "-", "-", "Wifi Shield IP(default 192.168.4.1)", "any local port which is free", "-", "-"
"Cyton Wifi", "BoardIds.CYTON_WIFI_BOARD (5)", "-", "-", "Wifi Shield IP(default 192.168.4.1)", "any local port which is free", "-", "-"
"Cyton Daisy Wifi", "BoardIds.CYTON_DAISY_WIFI_BOARD (6)", "-", "-", "Wifi Shield IP(default 192.168.4.1)", "any local port which is free", "-", "-"
Expand Down Expand Up @@ -114,6 +114,7 @@ Board Spec:
- num acceleration channels: 3
- sampling rate: 250
- communication: serial port
- signal gain: 24

Ganglion
~~~~~~~~~
Expand Down Expand Up @@ -171,6 +172,7 @@ Board Spec:
- num acceleration channels: 3
- sampling rate: 125
- communication: serial port
- signal gain: 24


Ganglion with Wifi Shield
Expand Down Expand Up @@ -233,6 +235,7 @@ Board Spec:
- num acceleration channels: 3
- sampling rate: 1000
- communication: TCP socket to read data and HTTP to send commands
- signal gain: 24

Cyton Daisy with Wifi Shield
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down Expand Up @@ -263,3 +266,4 @@ Board Spec:
- num acceleration channels: 3
- sampling rate: 1000
- communication: TCP socket to read data and HTTP to send commands
- signal gain: 24
42 changes: 42 additions & 0 deletions tests/cpp/get_data_demo/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,46 @@ target_link_libraries (
${BrainflowPath}
${DataHandlerPath}
${BoardControllerPath}
)

#################################
## Demo for data acquisition 2 ##
#################################
add_executable (
brainflow_get_data_twice
src/brainflow_get_data_twice.cpp
)

target_include_directories (
brainflow_get_data_twice PUBLIC
${brainflow_INCLUDE_DIRS}
)

target_link_libraries (
brainflow_get_data_twice PUBLIC
# for some systems(ubuntu for example) order matters
${BrainflowPath}
${DataHandlerPath}
${BoardControllerPath}
)

#################################
## Demo for config_board ##
#################################
add_executable (
brainflow_config_board
src/brainflow_config_board.cpp
)

target_include_directories (
brainflow_config_board PUBLIC
${brainflow_INCLUDE_DIRS}
)

target_link_libraries (
brainflow_config_board PUBLIC
# for some systems(ubuntu for example) order matters
${BrainflowPath}
${DataHandlerPath}
${BoardControllerPath}
)

0 comments on commit df123cf

Please sign in to comment.