Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
AranRhiod committed Jan 4, 2025
2 parents 055c439 + 4643c09 commit f5216c8
Show file tree
Hide file tree
Showing 105 changed files with 3,233 additions and 995 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/deploy_cpp_libs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ jobs:
max-parallel: 16
matrix:
build_type: [Release, Debug]
os: [ubuntu-latest, macos-12]
os: [ubuntu-latest, macos-13]

steps:
- name: Clone Repository
Expand All @@ -69,13 +69,13 @@ jobs:
with:
cmake-version: '3.21.x'
- name: Install Ninja
if: (matrix.os == 'macos-12')
if: (matrix.os == 'macos-13')
uses: seanmiddleditch/gha-setup-ninja@master
with:
version: 1.10.2
# build simpleble outside from brainflow because of different deployment targets
- name: Compile SimpleBLE MacOS
if: (matrix.os == 'macos-12')
if: (matrix.os == 'macos-13')
run: |
mkdir $GITHUB_WORKSPACE/third_party/SimpleBLE/simpleble/build
cd $GITHUB_WORKSPACE/third_party/SimpleBLE/simpleble/build
Expand All @@ -86,7 +86,7 @@ jobs:
env:
BUILD: ${{ matrix.build_type }}
- name: Compile BrainFlow for MacOS
if: (matrix.os == 'macos-12')
if: (matrix.os == 'macos-13')
run: |
mkdir $GITHUB_WORKSPACE/build
cd $GITHUB_WORKSPACE/build
Expand Down
18 changes: 10 additions & 8 deletions .github/workflows/run_unix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
fail-fast: false
max-parallel: 4
matrix:
os: [ubuntu-20.04, macos-12]
os: [ubuntu-20.04, macos-13]

steps:
# compile and prepare env
Expand Down Expand Up @@ -45,7 +45,7 @@ jobs:
run: |
npm install -g ts-node
- name: Install Ninja
if: (matrix.os == 'macos-12')
if: (matrix.os == 'macos-13')
uses: seanmiddleditch/gha-setup-ninja@master
with:
version: 1.10.2
Expand All @@ -63,15 +63,15 @@ jobs:
java-version: 11.0.3
# build simpleble outside from brainflow because of different deployment targets
- name: Compile SimpleBLE MacOS
if: (matrix.os == 'macos-12')
if: (matrix.os == 'macos-13')
run: |
mkdir $GITHUB_WORKSPACE/third_party/SimpleBLE/simpleble/build
cd $GITHUB_WORKSPACE/third_party/SimpleBLE/simpleble/build
cmake -G Ninja -DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" -DCMAKE_OSX_DEPLOYMENT_TARGET=10.15 -DCMAKE_INSTALL_PREFIX=$GITHUB_WORKSPACE/installed -DCMAKE_BUILD_TYPE=Release ..
ninja
ninja install
- name: Compile BrainFlow MacOS
if: (matrix.os == 'macos-12')
if: (matrix.os == 'macos-13')
run: |
mkdir $GITHUB_WORKSPACE/build
cd $GITHUB_WORKSPACE/build
Expand Down Expand Up @@ -154,7 +154,7 @@ jobs:
- name: Run unit tests
run: $GITHUB_WORKSPACE/build/tests/brainflow_tests
- name: Synthetic C# Test MacOS
if: (matrix.os == 'macos-12')
if: (matrix.os == 'macos-13')
run: |
cd $GITHUB_WORKSPACE/csharp_package/brainflow/examples/brainflow_get_data/bin/Release/net7.0
cp $GITHUB_WORKSPACE/installed/lib/libBoardController.dylib $GITHUB_WORKSPACE/csharp_package/brainflow/examples/brainflow_get_data/bin/Release/net7.0/
Expand All @@ -164,7 +164,7 @@ jobs:
LD_LIBRARY_PATH: ${{ github.workspace }}/installed/lib
DYLD_LIBRARY_PATH: ${{ github.workspace }}/installed/lib
- name: EEG Metrics C# Test MacOS
if: (matrix.os == 'macos-12')
if: (matrix.os == 'macos-13')
run: |
cd $GITHUB_WORKSPACE/csharp_package/brainflow/examples/eeg_metrics/bin/Release/net7.0
cp $GITHUB_WORKSPACE/installed/lib/libBoardController.dylib $GITHUB_WORKSPACE/csharp_package/brainflow/examples/eeg_metrics/bin/Release/net7.0/
Expand Down Expand Up @@ -234,7 +234,9 @@ jobs:
env:
LD_LIBRARY_PATH: ${{ github.workspace }}/installed/lib
- name: Cyton Daisy Python
run: sudo -H python3 $GITHUB_WORKSPACE/emulator/brainflow_emulator/cyton_linux.py python3 $GITHUB_WORKSPACE/python_package/examples/tests/brainflow_get_data.py --board-id 2 --serial-port
run: sudo -H python3 $GITHUB_WORKSPACE/emulator/brainflow_emulator/cyton_linux.py python3 $GITHUB_WORKSPACE/python_package/examples/tests/brainflow_get_data.py --board-id 2 --serial-port
- name: KnightBoard Python
run: sudo -H python3 $GITHUB_WORKSPACE/emulator/brainflow_emulator/knightboard_linux.py python3 $GITHUB_WORKSPACE/python_package/examples/tests/brainflow_get_data.py --board-id 57 --serial-port
- name: Cyton Daisy Python Markers
run: sudo -H python3 $GITHUB_WORKSPACE/emulator/brainflow_emulator/cyton_linux.py python3 $GITHUB_WORKSPACE/python_package/examples/tests/markers.py --board-id 2 --serial-port
- name: Galea Cpp
Expand Down Expand Up @@ -409,7 +411,7 @@ jobs:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
- name: Push Libraries MacOS Dev
if: ${{ github.event_name == 'push' && matrix.os == 'macos-12' && github.repository == 'brainflow-dev/brainflow' }}
if: ${{ github.event_name == 'push' && matrix.os == 'macos-13' && github.repository == 'brainflow-dev/brainflow' }}
run: |
aws s3 cp $GITHUB_WORKSPACE/installed/lib/ s3://brainflow/$GITHUB_SHA/macos_release --recursive
env:
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/run_windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,9 @@ jobs:
- name: FreeEEG32 Python Test
run: python %GITHUB_WORKSPACE%\emulator\brainflow_emulator\freeeeg32_windows.py python %GITHUB_WORKSPACE%\python_package\examples\tests\brainflow_get_data.py --board-id 17 --serial-port
shell: cmd
- name: KnightBoard Windows Python Test
run: python %GITHUB_WORKSPACE%\emulator\brainflow_emulator\knightboard_windows.py python %GITHUB_WORKSPACE%\python_package\examples\tests\brainflow_get_data.py --board-id 57 --serial-port
shell: cmd
# Signal Processing Testing
- name: Serialization Rust Test
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
fail-fast: false
max-parallel: 4
matrix:
os: [ubuntu-20.04, macos-12]
os: [ubuntu-20.04, macos-13]

steps:
# install dependencies
Expand Down
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ option (BUILD_PERIPHERY "BUILD_PERIPHERY" OFF)
include (${CMAKE_CURRENT_SOURCE_DIR}/cmake/macros.cmake)
configure_msvc_runtime ()

add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/utf-8>")
add_compile_options("$<$<C_COMPILER_ID:MSVC>:/utf-8>")

if (WARNINGS_AS_ERRORS)
if (MSVC)
add_compile_options (/WX)
Expand Down
15 changes: 15 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,18 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

IMPORTANT NOTICE: BrainFlow uses SimpleBLE,
which is owned by The California Open Source Company LLC and used under license.
As an End User of BrainFlow, you are prohibited from using, modifying, or
distributing SimpleBLE, or any part thereof, except as incorporated in this
Project. Specifically, you may not:

a) Extract, isolate, or separate SimpleBLE from BrainFlow;
b) Modify, adapt or translate SimpleBLE;
c) Distribute, sublicense, rent, lease, lend, or transfer SimpleBLE to any third party;
d) Remove, obscure, or alter any copyright, trademark, or other proprietary rights
notices contained within SimpleBLE.
Your use of this Application is subject to your compliance with these restrictions.
If you have any questions about these terms, please contact
The California Open Source Company LLC [[email protected]].
14 changes: 8 additions & 6 deletions csharp_package/brainflow/brainflow/board_controller_library.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,14 @@ public enum BoardIds
AAVAA_V3_BOARD = 53,
EXPLORE_PLUS_8_CHAN_BOARD = 54,
EXPLORE_PLUS_32_CHAN_BOARD = 55,
PIEEG_BOARD = 56,
SYNCHRONI_TRIO_3_CHANNELS_BOARD = 57,
SYNCHRONI_OCTO_8_CHANNELS_BOARD = 58,
OB5000_8_CHANNELS_BOARD = 59,
SYNCHRONI_PENTO_8_CHANNELS_BOARD = 60,
SYNCHRONI_UNO_1_CHANNELS_BOARD = 61,
PIEEG_BOARD = 56,
NEUROPAWN_KNIGHT_BOARD = 57
SYNCHRONI_TRIO_3_CHANNELS_BOARD = 58,
SYNCHRONI_OCTO_8_CHANNELS_BOARD = 59,
OB5000_8_CHANNELS_BOARD = 60,
SYNCHRONI_PENTO_8_CHANNELS_BOARD = 61,
SYNCHRONI_UNO_1_CHANNELS_BOARD = 62,

};


Expand Down
37 changes: 37 additions & 0 deletions docs/SupportedBoards.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1248,6 +1248,7 @@ To create such board you need to specify the following board ID and fields of Br

- :code:`BoardIds.EMOTIBIT_BOARD`
- *optional:* :code:`ip_address`, you can provide *broadcast* ip address of the network with EmotiBit device, e.g. 192.168.178.255. If not provided BrainFlow will try to autodiscover the network and it may take a little longer.
- *optional:* :code:`serial_number`, recommended you if have multiple boards in the same network.

Initialization Example:

Expand Down Expand Up @@ -1305,3 +1306,39 @@ Supported platforms:
**Note**: Ensure that you have the necessary permissions to access the serial port on your operating system. For Unix-like systems, you may need to configure permissions for the serial port or run with sudo.
**To use this board you need to compile BrainFlow from the source code right on your Raspbery Pi device with flag --build-periphery(build.py) or with -DBUILD_PERIPHERY=ON(CMake) and install desired bindings using local libraries.**
NeuroPawn
--------
Knight Board
~~~~~~~~~~~~~
.. image:: https://live.staticflickr.com/65535/54061606098_e223ab04a6_w.jpg
:width: 400px
:height: 274px
`NeuroPawn website <https://www.neuropawn.tech/>`_
To create such board you need to specify the following board ID and fields of BrainFlowInputParams object:
- :code:`BoardIds.NEUROPAWN_KNIGHT_BOARD`
- :code:`serial_port`, e.g. COM3, /dev/tty.*

Initialization Example:

.. code-block:: python
params = BrainFlowInputParams()
params.serial_port = "COM3"
board = BoardShim(BoardIds.NEUROPAWN_KNIGHT_BOARD, params)
**On Unix-like systems you may need to configure permissions for serial port or run with sudo.**

**On MacOS there are two serial ports for each device: /dev/tty..... and /dev/cu..... You HAVE to specify /dev/cu.....**

Supported platforms:

- Windows
- Linux
- MacOS
- Devices like Raspberry Pi
52 changes: 52 additions & 0 deletions emulator/brainflow_emulator/knightboard_emulator.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import logging
import threading
import time
from random import randint

class Listener(threading.Thread):

def __init__(self, port, write, read):
# for windows write and read are methods from Serial object, for linux - os.read/write it doesnt work otherwise
threading.Thread.__init__(self)
self.port = port
self.writer_process = None
self.write = write
self.read = read
self.need_stop = False

def run(self):
self.writer_process = KnightBoardWriter(self.port, 0.005, self.write)
self.writer_process.daemon = True
self.writer_process.start()
time.sleep(10)
self.writer_process.need_data = False
self.writer_process.join()


class KnightBoardWriter(threading.Thread):

def __init__(self, port, delay, write):
threading.Thread.__init__(self)
self.port = port
self.write = write
self.delay = delay
self.package_size = 21
self.package_num = 0
self.need_data = True

def run(self):
while self.need_data:
if self.package_num % 256 == 0:
self.package_num = 0

package = list()
package.append(0xA0)
package.append(self.package_num)
for i in range(2, self.package_size - 1):
package.append(randint(0, 255))
package.append(0xC0)
logging.info(bytes(package))
self.write(self.port, bytes(package))

self.package_num = self.package_num + 1
time.sleep(self.delay)
53 changes: 53 additions & 0 deletions emulator/brainflow_emulator/knightboard_linux.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import logging
import os
import pty
import subprocess
import sys

from brainflow_emulator.emulate_common import TestFailureError, log_multilines
from brainflow_emulator.knightboard_emulator import Listener


def write(port, data):
return os.write(port, data)


def read(port, num_bytes):
return os.read(port, num_bytes)


def get_ports_pty():
master, slave = pty.openpty()
s_name = os.ttyname(slave)
return master, slave, s_name


def test_serial(cmd_list, master, slave, s_name):
listen_thread = Listener(master, write, read)
listen_thread.daemon = True
listen_thread.start()

cmd_to_run = cmd_list + [s_name]
logging.info('Running %s' % ' '.join([str(x) for x in cmd_to_run]))
process = subprocess.Popen(cmd_to_run, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
stdout, stderr = process.communicate()

log_multilines(logging.info, stdout)
log_multilines(logging.info, stderr)

if process.returncode != 0:
raise TestFailureError('Test failed with exit code %s' % str(process.returncode), process.returncode)

return stdout, stderr


def main(cmd_list):
if not cmd_list:
raise Exception('No command to execute')
master, slave, s_name = get_ports_pty()
test_serial(cmd_list, master, slave, s_name)


if __name__ == '__main__':
logging.basicConfig(level=logging.INFO)
main(sys.argv[1:])
Loading

0 comments on commit f5216c8

Please sign in to comment.