openbci-archive/OpenBCI_NodeJS_Ganglion

Bug: Sample event never triggered

Closed this issue · 12 comments

I am using the Ganglion board on a Mac - OS-X El Capitan.
While I can connect to the board, I am unable to receive any data.

This is the code

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();

This is the output:

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 never receives any sample.

Assume everything looks good with the GUI?

Yes works fine with the GUI.
Thanks

Just glanced over your code and don't see why, this must be really frustrating, sorry @amiyapatanaik I'll copy and paste your code and try to dig deeper

@amiyapatanaik what version of node are you using?

This is exactly what I am experiencing on one of two devices I am using. See my issue for more details.

Yea I'm seeing this problem too. So bizarre. I need to try rolling back to an earlier version and see what broke.

@aj-ptw I am using Node JS v4.3.0

@aj-ptw confirming that I'm experiencing this exact issue as well, with similar code and console output. I'm on node v6.9.3 (npm v4.0.5), Ubuntu 16.04 LTS. Ganglion is streaming on the GUI, thouugh, just not through Node.

I for the life of me cannot find this bug! Any help is requested and asked for in regards to this issue!

Hi all this was because of noble v0.1.8 which was released four days ago. The GUI was built more than four days ago so it was built with noble v0.1.7. #24 will fix this by forcing v0.1.7 in the package.json

Open issue in noble noble/noble#554

@aj-ptw awesome...thanks for resolving this so quickly. I'll test it out tomorrow.
Cheers

thank @lpercifield ! he found it