Ganglion raw samples with node.js, Python or LSL widget?

AmiyaAmiya Singapore
edited February 2017 in Ganglion
Hi All,
I am trying to get access to the raw samples on the Ganglion board. The python SDK included asks for a port (which I presume does not exist for com over BLE). 

def __init__(self, port=None, baud=115200, filter_data=True,
               scaled_output=True, daisy=False, log=True, timeout=None):
    if not port:
        port = find_port()  <--- this function does not exist 
        if not port:
            raise OSError('open_bci_v4.py: Cannot find OpenBCI port')

I tried using the node js library, but I am unable to get samples out of it (even though it connects and starts streaming). Probably the best will be a LSL widget within the GUI itself in the form of a widget.

Please suggest a solution.
Thanks..

Comments

  • wjcroftwjcroft Mount Shasta, CA
    Correct, no COM port for Ganglion. Are you sure you were following AJ Keller's @pushtheworld tutorial for node?

    https://github.com/OpenBCI/OpenBCI_NodeJS_Ganglion

    There is also a node to Python pathway (NOT the code above which only works for Cyton.)

    https://github.com/OpenBCI/OpenBCI_NodeJS/tree/master/examples/python

  • AmiyaAmiya Singapore
    Hi @wjcroft ;
    Yes I am following the right one. In fact I can connect to the device but for some reason I just don't receive the 'sample' event triggered. 
    See the code below:

    const Ganglion = require('openbci-ganglion').Ganglion;
    const ganglion = new Ganglion({verbose: true});

    ganglion.once('ganglionFound', (peripheral) => {
      // Stop searching for BLE devices once a ganglion is found.
      ganglion.searchStop();
      
      ganglion.once('ready', () => {
        console.log('Device is ready to communicate.')
        ganglion.accelStop();
        ganglion.streamStart();
        ganglion.on('sample', (sample) => {
        /** Work with sample */
        console.log(sample.sampleNumber);
        for (var i = 0; i < ganglion.numberOfChannels(); i++) {
          console.log("Channel " + (i + 1) + ": " + sample.channelData[i].toFixed(8) + " Volts.");
        }
        });
        console.log('Streaming: ' + ganglion.isStreaming() + ' Channels: ' + ganglion.numberOfChannels() + ' Sampling Rate: ' + ganglion.sampleRate() + 'Hz');
      });
      ganglion.connect(peripheral);
      console.log("Found Device: " + ganglion.getLocalName())
    });
    // Start scanning for BLE devices
    ganglion.searchStart();

    The output is:







    p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo}
    span.s1 {font-variant-ligatures: no-common-ligatures}

    Bluetooth powered on

    Scan started

    Found ganglion!

    Stopping scan

    Scan stopped

    Device is advertising 'Ganglion-652d' service.

    Found Device: Ganglion-652d

    Discovered 3 service characteristics

    Found receiveCharacteristicUUID

    Found sendCharacteristicUUID

    Device is ready to communicate.

    Streaming: true Channels: 4 Sampling Rate: 200Hz

    Sent stream start to board.


    It just gets stuck at that. I have never used JS before but the code looks fine to me. Can someone point out what could be wrong??


    Thanks

  • wjcroftwjcroft Mount Shasta, CA
    Amiya, hi.

    Please open an issue here and AJ will see it,

    https://github.com/OpenBCI/OpenBCI_NodeJS_Ganglion/issues

  • AmiyaAmiya Singapore
    Thanks @wjcroft
    Submitted the issue.
    Cheers
  • This issue was resolved with the latest release `0.4.3` thanks everyone for the help https://github.com/OpenBCI/OpenBCI_NodeJS_Ganglion/releases/tag/v0.4.3
Sign In or Register to comment.