Giter Club home page Giter Club logo

openbci_nodejs_ganglion's People

Contributors

benjaminjnoack avatar daniellasry avatar gabrielibagon avatar jdpigeon avatar teonbrooks avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

openbci_nodejs_ganglion's Issues

Node Deprecation Warnings

Currently getting the following deprecation warnings when I run the example:

const Ganglion = require('openbci-ganglion').Ganglion;
const ganglion = new Ganglion();
ganglion.once('ganglionFound', (peripheral) => {
  // Stop searching for BLE devices once a ganglion is found.
  ganglion.searchStop();
  ganglion.on('sample', (sample) => {
    /** Work with sample */
    console.log(sample.sampleNumber);
    for (let i = 0; i < ganglion.numberOfChannels(); i++) {
      console.log("Channel " + (i + 1) + ": " + sample.channelData[i].toFixed(8) + " Volts.");
    }
  });
  ganglion.once('ready', () => {
    ganglion.streamStart();
  });
  ganglion.connect(peripheral);
});
// Start scanning for BLE devices
ganglion.searchStart();
(node:96316) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): Please turn blue tooth on.
(node:96316) DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

TypeError at openBCIGanglion.js:871

I'm running the TL;DR code on windows. Its connecting to the ganglion through the dongle but getting this error

`Bluetooth powered on
Scan started
Found ganglion!
Stopping scan
Device is advertising 'Ganglion-12f6' service.
Scan stopped
C:\Users\COld\node_modules\openbci-ganglion\openBCIGanglion.js:871
this._rfduinoService.once(k.OBCINobleEmitterServiceCharacteristicsDiscover, (characteristics) => {
^

TypeError: Cannot read property 'once' of null
at Peripheral._peripheral.on (C:\Users\COld\node_modules\openbci-ganglion\openBCIGanglion.js:871:27)
at emitOne (events.js:96:13)
at Peripheral.emit (events.js:188:7)
at Noble.onServicesDiscover (C:\Users\COld\node_modules\noble\lib\noble.js:247:16)
at emitTwo (events.js:106:13)
at NobleBindings.emit (events.js:191:7)
at NobleBindings.onServicesDiscovered (C:\Users\COld\node_modules\noble\lib\hci-socket\bindings.js:305:8)
at emitTwo (events.js:106:13)
at Gatt.emit (events.js:191:7)
at Gatt. (C:\Users\COld\node_modules\noble\lib\hci-socket\gatt.js:361:12)`

'accelerometer' events will be never fired

Hi, I'm really enjoying using Ganglion and this Node.js SDK. really great works!

now i'm trying to fetch x-y-z axis accelerometer's data from the board, like ganglion.on('accelerometer',(data) => {...} but the Ganglion never fire the 'accelerometer' events and nothing I can get.

I tried to dig into the SDK's source code, and I found that the event is fired on the below code block.

// openBCIGanglion.js - line 842
Ganglion.prototype._processCompressedData = function (data) {
  // Save the packet counter
  this._packetCounter = parseInt(data[0]);
  // Decompress the buffer into array
  if (this._packetCounter <= k.OBCIGanglionByteId18Bit.max) {
    this._decompressSamples(ganglionSample.decompressDeltas18Bit(data.slice(k.OBCIGanglionPacket18Bit.dataStart, k.OBCIGanglionPacket18Bit.dataStop)));
    switch (this._packetCounter % 10) {
      case k.OBCIGanglionAccelAxisX:
        this._accelArray[0] = this.options.sendCounts ? data.readInt8(k.OBCIGanglionPacket18Bit.auxByte - 1) : data.readInt8(k.OBCIGanglionPacket18Bit.auxByte - 1) * k.OBCIGanglionAccelScaleFactor;
        break;
      case k.OBCIGanglionAccelAxisY:
        this._accelArray[1] = this.options.sendCounts ? data.readInt8(k.OBCIGanglionPacket18Bit.auxByte - 1) : data.readInt8(k.OBCIGanglionPacket18Bit.auxByte - 1) * k.OBCIGanglionAccelScaleFactor;
        break;
      case k.OBCIGanglionAccelAxisZ:
        this._accelArray[2] = this.options.sendCounts ? data.readInt8(k.OBCIGanglionPacket18Bit.auxByte - 1) : data.readInt8(k.OBCIGanglionPacket18Bit.auxByte - 1) * k.OBCIGanglionAccelScaleFactor;
        this.emit(k.OBCIEmitterAccelerometer, this._accelArray);
        break;
      default:
        break;
    }

and finally I found that the this._packetCounter value is always more than k.OBCIGanglionByteId18Bit.max, in other words, always data[0] > 100.

here is the result of debugging the this._packetCounter value on my console.
2017-02-25 0 48 05
the value is always fall between 101 - 200 (when it reaches 200, the next value is 101, not 0, and why is it never less than 100 ?

Another app, I mean, OpenBCI GUI (processing app) can take the accelerometer's value correctly, so I assume that the Ganglion board emits correct value.

is this problem already known one? or do I some mistakes?
and where can i find any references about openBCI's event emitting systems?

I'll really appreciate your help, thanks.

openbci-ganglion depends on bluetooth-hci-socket, which is abandoned and doesn't build with node 10

openbci-ganglion fails to install with node v10, due to a broken dependency, bluetooth-hci-socket.

$ node -v
v10.13.0
npm install @openbci/ganglion

...

../src/BluetoothHciSocket.cpp: In member function ‘void BluetoothHciSocket::emitErrnoError()’:
../src/BluetoothHciSocket.cpp:275:72: error: no matching function for call to ‘v8::Function::NewInstance(int, v8::Local<v8::Value> [1])’
   Local<Value> error = errorConstructor->NewInstance(1, constructorArgs);
                                                                        ^
In file included from /home/mhirsch/.node-gyp/10.13.0/include/node/node.h:63,
                 from /home/mhirsch/.node-gyp/10.13.0/include/node/node_buffer.h:25,
                 from ../src/BluetoothHciSocket.cpp:7:

...

gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/lib/node_modules/node-gyp/lib/build.js:258:23)
gyp ERR! stack     at ChildProcess.emit (events.js:182:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:240:12)
gyp ERR! System Linux 4.18.18-300.fc29.x86_64
gyp ERR! command "/usr/bin/node" "/usr/bin/node-gyp" "rebuild"
gyp ERR! cwd /home/mhirsch/Projects/OpenBCI/node_modules/bluetooth-hci-socket
gyp ERR! node -v v10.13.0
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok 
npm WARN enoent ENOENT: no such file or directory, open '/home/mhirsch/Projects/OpenBCI/package.json'
npm WARN OpenBCI No description
npm WARN OpenBCI No repository field.
npm WARN OpenBCI No README data
npm WARN OpenBCI No license field.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/xpc-connection):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

See the issue with bluetooth-hci-socket here

noble/node-bluetooth-hci-socket#84

The project should migrate away from this abandoned dependency.

Reliably crashes every time after running for about 10 seconds.

Running on Mac OSX Sierra.

I have changed the code only slightly because I'm trying to get it to output to python. I don't think I did anything that would affect the connection to the board.

Here is an example output. Every time I run it, it looks something like this.

GanglionNodeCrashLog.txt

Also just to confirm it's not a hardware issue, everything is fine on OpenBCI GUI.

Error: Cannot find module 'openbci-ganglion'

Hello everyone,
I do all the things as told in instructions
installed all the prerequisites
but when i try to run this command in in Node js const "Ganglion = require('openbci-ganglion');"
it syas
Error: Cannot find module 'openbci-ganglion'
i had installed the openbci-ganglion module and it is showing in list of modules using
npm list -g --depth=0

Installation instructions for Linux should mention node BLE privileges

Just set this up today on my Linux and ran into an issue when trying to run a script that used both openbci-ganglion and python-shell.

the noble dependency prompted me to run the script as sudo to access where noble was prompting me to run the node script as sudo in order to access BLE privileges. However, this caused a mess in the python scripts because of the whole complicated *nix user/root different python path issue.

The fix ended up being following the instructions on the noble README to allow node to access BLE privileges without sudo.

Perhaps that simple fix should be added to the README here to avoid tripping up future Linux users.

I'm happy to make the PR if you guys want

Cannot disable a channel

I'm trying to disable a channel, but adding a call to channelOff causes no samples to show up.

Here's the code that I'm testing with:

const Ganglion = require('openbci-ganglion');
const ganglion = new Ganglion({ debug: true });
ganglion.once('ganglionFound', (peripheral) => {
    ganglion.searchStop();
    ganglion.on('sample', (sample) => {
        console.log(sample.sampleNumber);
        for (let i = 0; i < ganglion.numberOfChannels(); i++) {
            console.log('Channel ' + (i + 1) + ': ' + sample.channelData[i].toFixed(8) + ' Volts.');
        }
    });
    ganglion.once('ready', () => {
        ganglion.channelOff(4);
        ganglion.streamStart();
    });
    ganglion.connect(peripheral);
});
ganglion.searchStart();

Here's the output on stdout:

Debug bytes:
>>>  62                                                |b|
Debug bytes:
>>>  34                                                |4|
Debug bytes:
<<  ce 44 65 61 63 74 69 76  61 74 69 6e 67 20 63 68  |.Deactivating ch|
<<  61 6e 6e 65                                       |anne|
Debug bytes:
<<  cf 6c 20 34 0a                                    |.l 4.|

There are no calls to the sample event handler. If I comment out the ganglion.channelOff(4); line, it behaves normally.

I'm using a MacBook Pro (mid-2015) running Mac OS X 10.13.2.

Bug: Sample event never triggered

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.