openbci-archive/OpenBCI_NodeJS_Ganglion

Reliably crashes every time after running for about 10 seconds.

mgroth0 opened this issue · 12 comments

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.

It looks like you are dropping packets like crazy. I wonder if you have an event emitter issue here, sort of what it looks like.

I tried again using the completely unaltered master code.

GanglionNodeCrashLog2.txt

Please let me know if there is anything I can do to help solve this.

Also, 10 seconds was a bad estimation. I'd say average 2-3 seconds.

Again using the master repo, I only added 5 lines to the code to help determine the cause of the dropped packets. I added a log for each condition that could cause _droppedPacket to run.

I ran connect-test and did a search in the terminal output to find the number of times each _droppedPacket case occurred.

case 1: 0
case 2: 0
case 3: 5
case 4: 81
case 5: 695

GanglionPacketDropInvestigationLog.txt

My altered code is included below to identify each case.

It might take me a while to dig through and figure out what all of this means, so if anyone could give me a quick description of these variables in the context of dropped packets, that could be helpful.

  • curByteId
  • difByteId
  • tempCounter

`
/**

  • Checks for dropped packets
  • @param data {Buffer}
  • @Private
    */
    Ganglion.prototype._processProcessSampleData = function(data) {
    const curByteId = parseInt(data[0]);
    const difByteId = curByteId - this._packetCounter;

if (this._firstPacket) {
this._firstPacket = false;
this._processRouteSampleData(data);
return;
}

// Wrap around situation
if (difByteId < 0) {
if (this._packetCounter <= k.OBCIGanglionByteId18Bit.max) {
if (this._packetCounter === k.OBCIGanglionByteId18Bit.max) {
if (curByteId !== k.OBCIGanglionByteIdUncompressed) {
console.log('Packet Drop case 1');
this._droppedPacket(curByteId - 1);
}
} else {
let tempCounter = this._packetCounter + 1;
while (tempCounter <= k.OBCIGanglionByteId18Bit.max) {
console.log('Packet Drop case 2');
this._droppedPacket(tempCounter);
tempCounter++;
}
}
} else if (this._packetCounter === k.OBCIGanglionByteId19Bit.max) {
if (curByteId !== k.OBCIGanglionByteIdUncompressed) {
console.log('Packet Drop case 3');
this._droppedPacket(curByteId - 1);
}
} else {
let tempCounter = this._packetCounter + 1;
while (tempCounter <= k.OBCIGanglionByteId19Bit.max) {
console.log('Packet Drop case 4');
this._droppedPacket(tempCounter);
tempCounter++;
}
}
} else if (difByteId > 1) {
if (this._packetCounter === k.OBCIGanglionByteIdUncompressed && curByteId === k.OBCIGanglionByteId19Bit.min) {
this._processRouteSampleData(data);
return;
} else {
let tempCounter = this._packetCounter + 1;
while (tempCounter < curByteId) {
console.log('Packet Drop case 5');
this._droppedPacket(tempCounter);
tempCounter++;
}
}
}
this._processRouteSampleData(data);
};
`

Hey Matt,

Can you please try on a different computer? I'm sorry you're having all these problems, as another dev, this sounds incredibly frustrating!

Hey AJ,

I'm actually a student not a dev, so this has been a fun learning experience for me! And I really appreciate that you are regularly responding, which is making this totally bearable.

The only problem is I have a thesis experiment I need to run with this device so I'm kind of in a rush.

Here's the results from testing this on another iMac:

`LTS’s-MacBook-Pro:OpenBCI_NodeJS_Ganglion-master makerlab2$ npm run connect-test

openbci-ganglion@0.4.2 connect-test /Users/makerlab2/Documents/OpenBCI_NodeJS_Ganglion-master
node examples/ganglionConnectionTest/ganglionConnectionTest.js

starting 0
fullGangFunc
noble is NOT ready so waiting starting scan
Bluetooth powered on
Scan started
Found ganglion!
woo
Stopping scan
Scan stopped
search stopped
Device is advertising 'Ganglion-c97f' service.
Discovered 3 service characteristics
Found receiveCharacteristicUUID
Found sendCharacteristicUUID
Sent stream start to board.
disconnecting 0
stop streaming
Peripheral disconnected
Private disconnect clean up
Private disconnect clean up
starting 1
fullGangFunc
noble is ready so starting scan
Scan started
disconnecting 1
you were never connected on index 1
killFunc msg: failed to connect
clean
LTS’s-MacBook-Pro:OpenBCI_NodeJS_Ganglion-master makerlab2$
`

Just like what was reported by @amiyapatanaik here.

Also see the issue I created concerning the same iMac for OpenBCI GUI here.

I tried 0.4.3 on both my Macbook and the iMac from yesterday, and both continue to have their same respective problems. On the MacBook I get a lot of dropped packets, on the iMac I get no samples at all. Both disconnect after a few seconds.

Please make sure to remove your node_modules folder and then reinstall. Just make sure noble is 1.7

Please keep in mind you are using a connection test file that is supposed to end after a set amount of time. ganglionServer.js is what should be used.

I'm going to close this issue because the code you are running is supposed to stop after 10 seconds, please see this https://github.com/OpenBCI/OpenBCI_NodeJS_Ganglion/blob/master/examples/ganglionConnectionTest/ganglionConnectionTest.js#L92 line

Please checkout this code https://github.com/OpenBCI/OpenBCI_NodeJS/tree/master/examples/python from the main repo which get's the data over to python. Adapt this code for ganglion and you should be good to go!

@aj-ptw

Sorry about not understanding the main scripts before posting, thanks for the update and fix!

A couple of questions:

  1. I still have regularly dropped packets (see this log). Is that expected or is this a problem we still need to solve? I'm not familiar with what exactly a dropped packet is.

  2. I heard from @gabrielibagon that LSL support is coming to OpenBCI GUI soon. Since BCILab might be the best candidate for neurofeedback for me right now, this could be important. Could you update me on this development? I know it's possible to get to LSL through python, but it would still be nice to know if I may have this option as well.

Thanks so much!

I still have regularly dropped packets (see this log). Is that expected or is this a problem we still need to solve? I'm not familiar with what exactly a dropped packet is.

Not sure, this sounds like a software bug in the mac itself with bluetooth. My MacBook air does the same thing but when i run a ubuntu virtual machine inside my MacBook air there are no dropped packets. Please open a different issue for this.

I heard from @gabrielibagon that LSL support is coming to OpenBCI GUI soon. Since BCILab might be the best candidate for neurofeedback for me right now, this could be important. Could you update me on this development? I know it's possible to get to LSL through python, but it would still be nice to know if I may have this option as well.

No idea, please check with Gabe or open an issue on the OpenBCI_GUI :)