What is supposed to be put in lieu of the dev path in the last line of the example?
Betapig1 opened this issue ยท 21 comments
mw.connect('/dev/cu.MindWaveMobile-DevA');
What is supposed to be put in there, and how do I get it?
That is the serial-device it registers. I think that is the device it registers on Mac. What operating system are you using?
I think on any operating system, you can do this (if you have nodejs installed) to get a list of serial ports:
npx @serialport/list
Then you can pick the one that looks right from the list (either it has "mindwave" in it's name, or it changes, when you unplug and plug it back in)
I have an option between windows and mac. And so when I do the tutorial program I just put in the data attatched to the port? Also when i try to run that in admin command prompt i get this error
`C:\WINDOWS\system32>npx @serialport/list
internal/fs/utils.js:314
throw err;
^
Error: EPERM: operation not permitted, unlink 'C:\Users\Ryna\AppData\Roaming\npm-cache_npx\37840\node_modules@serialport\list\node_modules@serialport\bindings\build\Release\bindings.node'
at Object.unlinkSync (fs.js:1251:3)
at fixWinEPERMSync (C:\Program Files\nodejs\node_modules\npm\node_modules\rimraf\rimraf.js:219:13)
at rimrafSync (C:\Program Files\nodejs\node_modules\npm\node_modules\rimraf\rimraf.js:319:28)
at C:\Program Files\nodejs\node_modules\npm\node_modules\rimraf\rimraf.js:350:5
at Array.forEach ()
at rmkidsSync (C:\Program Files\nodejs\node_modules\npm\node_modules\rimraf\rimraf.js:349:26)
at rmdirSync (C:\Program Files\nodejs\node_modules\npm\node_modules\rimraf\rimraf.js:342:7)
at fixWinEPERMSync (C:\Program Files\nodejs\node_modules\npm\node_modules\rimraf\rimraf.js:217:5)
at rimrafSync (C:\Program Files\nodejs\node_modules\npm\node_modules\rimraf\rimraf.js:319:28)
at C:\Program Files\nodejs\node_modules\npm\node_modules\rimraf\rimraf.js:350:5 {
errno: -4048,
syscall: 'unlink',
code: 'EPERM',
path: 'C:\Users\Ryna\AppData\Roaming\npm-cache\_npx\37840\node_modules\@serialport\list\node_modules\@serialport\bindings\build\Release\bindings.node'
}`
I don't use windows, so I'm not sure. you might need to give it admin permissions to list serial ports (run your terminal via "run as admin" or whatever)
You can also do this in code, in the same dir:
const SerialPort = require('serialport')
SerialPort.list().then(ports => {
console.log(ports)
})
but I have a feeling it will need the same permissions.
In the error it says syscall: 'unlink'
so that seems unrelated to permissions of listing serial ports (might be a faulty nodejs install or something.) If I am understanding the error right, it's saying it can't delete the native (.node
) binding file.
unlink 'C:\Users\Ryna\AppData\Roaming\npm-cache_npx\37840\node_modules@serialport\list\node_modules@serialport\bindings\build\Release\bindings.node'
Ah so I just tried it on my mac and got a similar things as in the the example. So i literally just copy and paste that into the connect and it should connect to the headset properly?
Yep, could be a problem with npx on your win-box, so maybe try the code example above (which might be better to select the serial-port, if you are using it with multiple operating systems.)
If you like, I can whip up a quick "which serial port do you want to use?" example.
if its not too much trouble that'd be great! I'm literally just starting out with this tech cuz I just found out my schools lab has one lol
Yep, no prob. I'll whip one up real quick. You will still have to figure out which port it is (form a list), which will be trickier on windows, maybe. I have only tested on linux & mac (and briefly on windows a long time ago.) It basically relies on the serialport lib, which has really good cross-platform support, this lb is just a wrapper around that, which speaks the right protocol for the mindwave headset.
https://github.com/konsumer/mindwave-example
I did a quick test, and it just quit right away, not sure why. Maybe it needs a headset attached. I don't have a headset to test with handy (it's deep in a box somewhere.)
You can see I just use getSerialPort()
to ask which serial-port to attach to.
Okay thank you! Also one more question, i tried downloading the tutorial application on my mac and i cant open it. My only guess is its too old an os. Would you know of any old downlaod links?
Not sure what you mean by "tutorial application". Do you mean mindgraph? The source is in the repo, so if you can install node (and the build-tools it needs like the xcode cli tools) you should be able to build it yourself:
git clone https://github.com/brainbang/mindgraph.git
cd mindgraph
npm i
npm start
It might work without anything other than nodejs installed (using prebuilt binaries it downloads and stuff.)
You can build a version for your OS with npm run build
in the same dir.
Oh my apologies, I meant the mindwave mobile tutorial application. I was under the impression you had to install it to set up the headset
I'm still not really following, and don't know what that is. This just uses the serialport that mindwave opens up, and should work without anything else.
Sorry i was basing my info off this tutorial i saw https://www.youtube.com/watch?v=2hWqZ_gwmJQ
Ah, I don't work for Neurosky or anything.
It should work fine without all that, if you get the basic hardware setup (bluettoth paired, etc). Might be good to test it in the "official way" before working with this code, as I'm sure I did that years ago when I initially wrote this.
If I remember right, there are 2 interfaces:
- the low-level serial interface
- the wrapper thing neurosky made that runs in the tray and lets you connect in a web page
Mine uses the first, so you don't need anything else for low-level connection to the hardware. To connect to he second, you should be able to use regular web stuff and follow their tutorials, without node or anything else (just make it in the browser.)
It's been a very long time since I worked on this stuff, so I may be remembering it wrong.
kk, thank you so much for your help!
No prob. Marking closed, but feel free to ask more questions, if they come up.
If you are using mobile, it might work completely different, but maybe not. this is all for the standard bluetooth headset
I could be wrong, but I think they are the same thing, both bluetooth devices that pair and act like a serial port, whcih software like this can read directly, or you can install their little tray-app and use a web-browser to talk to it.
Actually, I just looked through docs & watched that video, and I think they work exactly the same. The "think gear connector" is that second thing I listed above, and is not needed for this library to work. If you are interested in using that, it's also totally an option. You basically just need to use something to adapt the raw serial messages to something you can use in your code, which can either be this library or their thing.
If you do chose to use theirs, you can use these docs to work out how to talk to it. Their thing basically just opens a service that talks JSON, so open a TCP socket to 127.0.0.1:13854
and follow the protocol guide to talk to it.
Personally, I think it's much easier to just talk to it directly over serial and do what you need to do (which is why I wrote this library) but both seem like a viable option (except there is no linux version of thinkgear, so it's not as good for cross-platform.)