Portname in linux for NodeJS

brownjonkentbrownjonkent United States
Hey guys,

New to the OpenBCI world, so please forgive the newbie question.

I've got the Cyton board up and running, and I'm seeing ECG data on the GUI... heart rate is coming through great.  

I'm now trying to get access to the signal data through NodeJS (following the youtube video: https://www.youtube.com/watch?v=jcYXFc4geoM)

I just cannot seem to get the portname to have my code find the board.  I'm running linux and see the board as "/dev/ttyUSB0" - validated in the GUI.

Here's my code and below that is what I'm seeing in the log:
const Cyton = require('./node_modules/openbci-cyton');

const ourBoard = new Cyton(
{
verbose: true //debug: true
}
);

var portName="/dev/ttyUSB0";

ourBoard.connect(portName).then(connection_success, connectbad);

function connection_success(portName) {
console.log('board found on ', portName);
ourBoard.on('ready', function() {
ourBoard.streamStart().then(null,null);
ourBoard.on('sample', function (sample) {
console.log('heard something');
console.log(sample.channelData[0])
});
});
}

function connectbad () {
console.log('no board found');
}

/usr/local/bin/node --inspect-brk=42260 project.js 
Debugger listening on ws://127.0.0.1:42260/769dd8f8-7b86-4567-97af-a11f2aa43071

Debugger attached.
using real board /dev/ttyUSB0
Serial port connected
no board found

Comments

  • wjcroftwjcroft Mount Shasta, CA
    Alex @alexcastillo has some NodeJS tutorials on his site, see if something here might be helpful,



    The at-mention above will also send Alex an email notification. You can click on his bold username, then use the Message button to send a PM to him.

    William

  • brownjonkentbrownjonkent United States
    Thanks William!

    I found the port after realizing that I needed to start the OpenBCU_GUI with the sudo command.  For some reason that worked perfectly.
Sign In or Register to comment.