establish BrainFlow connection between Cyton-Daisy and Jetson Nano [resolved]

jj_hennessyjj_hennessy United States
edited March 2020 in Cyton

I am working on getting my Ultracortex Mark IV w/ Cyton-Daisy (16 channel) working on my Jetson Nano. After not being able to get the OpenBCI Hub connected to the OpenBCI GUI, I'm now moving onto using Brainflow to stream the raw EEG data, but am unfortunately encountering some issues. I'm running the code:

from pyOpenBCI import OpenBCICyton
def print_raw(sample):
    print(sample.channels_data)

board = OpenBCICyton(daisy = True)
board.start_stream(print_raw)

but am getting the error:

raise OSError('Cannot find OpenBCI port.')
OSError: Cannot find OpenBCI port.

I know that the official OpenBCI team probably hasn't thoroughly tested running on the Jetson Nano, but does anyone have suggestions as to what I should do? Any help or tips would be greatly appreciated. Thanks in advance!

~JJ

Comments

  • wjcroftwjcroft Mount Shasta, CA

    You said you were moving to BrainFlow? Yet the above code seems to be using pyOpenBCI.

    https://brainflow.readthedocs.io/en/stable/Examples.html

  • jj_hennessyjj_hennessy United States

    @wjcroft You're right, I mispoke. The code I was using was pyOpenBCI, not Brainflow. I successfully installed Brainflow on my Nano, but when I run the example code called Python Get Data From a Board using the command:
    sudo python3 brainflow-first-stream.py --serial-port COM8 --board-id 0
    I get the following output:

        Traceback (most recent call last):
          File "brainflow-first-stream.py", line 54, in <module>
            main ()
          File "brainflow-first-stream.py", line 37, in main
            BoardShim.disable_board_logger ()
          File "/home/jj/.local/lib/python3.6/site-packages/brainflow/board_shim.py", line 394, in disable_board_logger
            cls.set_log_level (LogLevels.LEVEL_OFF.value)
          File "/home/jj/.local/lib/python3.6/site-packages/brainflow/board_shim.py", line 382, in set_log_level
            res = BoardControllerDLL.get_instance ().set_log_level (log_level)
          File "/home/jj/.local/lib/python3.6/site-packages/brainflow/board_shim.py", line 100, in get_instance
            cls.__instance = cls ()
          File "/home/jj/.local/lib/python3.6/site-packages/brainflow/board_shim.py", line 127, in __init__
            self.lib = ctypes.cdll.LoadLibrary (full_path)
          File "/usr/lib/python3.6/ctypes/__init__.py", line 426, in LoadLibrary
            return self._dlltype(name)
          File "/usr/lib/python3.6/ctypes/__init__.py", line 348, in __init__
            self._handle = _dlopen(self._name, mode)
        OSError: /home/jj/.local/lib/python3.6/site-packages/brainflow/lib/libBoardController.so: cannot open shared object file: No such file or directory
    

    After doing some research around this issue, I've realized that this likely means there is no compatible library with that name in the library cache. To try to resolve this I added the path /home/jj/.local/lib/python3.6/site-packages/brainflow/lib to my computer's ld.so.conf file (located in etc/) and ran sudo ldconfig to update library cache, but this didn't work. Do you have any idea what could be causing this?

  • wjcroftwjcroft Mount Shasta, CA

    JJ, hi.

    Mentioning Andrey @andrey1994 Parfenov, BrainFlow founder.

    When you unplug, plug in the dongle to the machine, do you see a serial port device appear in the /dev folder? What is the name, read/write permissions (ls -l /dev)? The earlier pyOpenBCI error may have been due to a device name mismatch or permissions issue. The Nano runs what variant of Linux? If it is Ubuntu as the search results suggest, you might have a file permissions issue with the device. It needs to have both read and write permissions for owner or group. And sometimes those are only turned on for a particular group by default.

    https://www.google.com/search?q=ubuntu+serial+port+group+permissions

    You can add yourself to the 'dialout' group with the shell command: sudo usermod -a -G dialout [yourusername]

    https://www.google.com/search?as_q=linux+dialout&as_sitesearch=openbci.com

    Regards, William

  • wjcroftwjcroft Mount Shasta, CA

    Additionally, the command example you gave uses a Windows format device name 'COM8', not Linux device name. Check the documentation.

  • jj_hennessyjj_hennessy United States

    William, thank you for the reply!
    To answer your question, yes, the serial port device ttyUSB0 appears in my /dev folder when it's plugged in. If I do an ls -l /dev, I get the following output from ttyUSB0:

    crw-rw-rw- 1 root dialout 188, 0 Mar 30 01:10 ttyUSB0

    I'm running Ubuntu 18.04 LTS. I tried all of the following, but am still receiving the same error:
    1. sudo usermod -a -G dialout jj (and then rebooting and replugging in)
    2. Following the steps in this guide (and then rebooting and replugging in)
    3. sudoedit /etc/udev/rules.d/50-ttyusb.rules and then adding the following code:
    KERNEL=="ttyUSB[0-9]*",NAME="tts/USB%n",SYMLINK+="%k",GROUP="uucp",MODE="0666"

    If there is any other helpful information I can give you about my system configuration please feel free to ask. I'm completely stumped on this one.

  • First of all as @wjcroft mentioned COM8 is definitely wrong serial port and you need to find a correct one using ls -l /dev/ and add user to dialout group if you want to run it without sudo.
    For BrainFlow I dont provide compiled libraries for ARM in general and for jetson nano particularly, but you still might be able to run it if you compile it by yourself directly on jetson. If you have 64bit OS and 64bit compiler it as simple as https://brainflow.readthedocs.io/en/stable/BuildBrainFlow.html#linux and after that https://brainflow.readthedocs.io/en/stable/BuildBrainFlow.html#python
    Since we never considered 32bit Linux, to build it on 32bit Linux machine maybe some minor changes in lib names are required specially in CMakeLists.txt, setup.py and in code which performs dlopen in python

  • after compilation you will need to reinstall python package using

    cd python-package
    python -m pip install -e .
    

    dont install it from PYPI

  • jj_hennessyjj_hennessy United States

    @Andrey1994 Thank you so much for your suggestions, I got the script running and successfully retrieving data from my Cyton-Daisy! For anybody else who is having issues running Brainflow on their Jetson Nano, follow these steps:
    1. Uninstall brainflow if it's already installed (pip uninstall brainflow or pip3 uninstall brainflow)
    2. Download the brainflow library into your desktop folder (or any other preferred location) and follow the steps here. The commands you'll need to run are:

    python -m pip install cmake==3.13.3
    ./tools/build_linux.sh
    
    1. Next, follow the steps listed here. Navigate to the brainflow library and run the below commands:

      cd python-package
      python -m pip install -e .
      

    Once again, thank you for everybody's help in resolving this issue! I greatly appreciate it :smile:

  • glad to heat that it just works, btw @wjcroft if you know any CI systems like travis,appveyour, circle ci which are free for open souce projects and supports ARM we can set up automatic tests for ARM too

  • and I wanna use jetson nano for my own projects with brainflow too, so feel free to ask or share you results

  • jj_hennessyjj_hennessy United States

    @Andrey1994 I'll definitely let you know if I run into more compatibility issues. This is unrelated to this particular thread, but when do you expect the OpenBCI Hub to be completely eliminated and replaced by Brainflow? Sometime in the next few months? It would be nice to have the OpenBCI GUI so that I can make sure all the channels are connected properly and not railing before I use Brainflow to collect the EEG stream. As I mentioned previously, the GUI is currently unusable on the Jetson Nano due to the OpenBCI Hub.

  • In GUI 5.0 and I think it will be released soon, more likely smth like ~month. If you need smth like visualizer right now maybe one of these 2 apps will do the trick on jetson https://brainflow.readthedocs.io/en/stable/Gallery.html

  • Another nice feature of brainflow - streaming board, it allows you to start streaming on jetson and stream data from jetson via multicast socket to another process on your PC, so in theory you can use streaming board on your desktop with mne scan or timeflux

Sign In or Register to comment.