Comparing version 1.0.0 to 1.1.0
{ | ||
"name": "node-muse", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "An event driven OSC message receiver for the Muse Brainwave Band made with Node.JS.", | ||
@@ -26,3 +26,3 @@ "main": "src/index.js", | ||
"dependencies": { | ||
"osc": "^1.1.0", | ||
"osc": "^2.0.1", | ||
"tree-kill": "^0.1.1" | ||
@@ -29,0 +29,0 @@ }, |
@@ -5,5 +5,5 @@ # Node Muse | ||
> An event driven OSC message receiver for the Muse Brainwave Band made with Node.JS. | ||
> An NPM module which provides an event driven OSC message receiver for the Muse Brainwave Band. | ||
This module will create a server which automatically connects to the Muse, keeps the connection open and reconnects if necessary. | ||
This NPM module will create a server which automatically connects to the Muse, keeps the connection open and reconnects if necessary. | ||
During the open connection the server will receive all of the signals the Muse has to offer and translates them to neat little strings and objects. | ||
@@ -106,2 +106,2 @@ The open server offers an observer type pattern, allowing the user to subscribe to these signals in an event driven way. | ||
As seen here: [GPLv3 License](./LICENSE) | ||
As seen here: [GPLv3 License](./LICENSE) |
@@ -171,2 +171,10 @@ /** | ||
// On unexpected error | ||
self.childspawn.on('error', function(data) { | ||
// TODO: Catch unexpected error | ||
if(self.debug){ | ||
console.log(data); | ||
} | ||
}); | ||
// On unexpected close | ||
@@ -173,0 +181,0 @@ self.childspawn.on('close', function(data) { |
@@ -66,3 +66,3 @@ /** | ||
// Create an osc.js UDP connection | ||
// Create an osc.js UDP connection to receive incoming OSC data | ||
this.udpPort = new osc.UDPPort({ | ||
@@ -75,3 +75,16 @@ localAddress: options.host, | ||
this.udpPort.on("data", function (data, info) { | ||
self.emit("data", osc.readMessage(data), info, data); | ||
// Prepare an error for when the try catch fails, inside the try this variable will get overridden | ||
var receivedData = { | ||
address : "error", | ||
args : ["The header of an OSC packet didn't contain an OSC address or a #bundle string"] | ||
}; | ||
try { | ||
receivedData = osc.readMessage(data); | ||
} catch(e) { | ||
if(self.debug) { | ||
console.log(e); | ||
} | ||
} | ||
self.emit("data", receivedData, info, data); | ||
}); | ||
@@ -82,3 +95,3 @@ | ||
if(self.debug) { | ||
console.log("OSC connection opened at: " + self.host + ":" + self.port); | ||
console.log("OSC connection opened at: " + options.host + ":" + options.port); | ||
} | ||
@@ -85,0 +98,0 @@ }); |
@@ -73,4 +73,6 @@ /** | ||
Muse.init({"not": "a", "valid":"argument"}); | ||
var spawnArgs = Muse.childspawn.spawnargs[2].replace("osc.udp://", "").split(":"); | ||
expect(spawnArgs[0] === "127.0.0.1" && spawnArgs[1] === "5002").toBe(true); | ||
if(typeof Muse.childspawn.spawnargs !== "undefined") { | ||
var spawnArgs = Muse.childspawn.spawnargs[2].replace("osc.udp://", "").split(":"); | ||
expect(spawnArgs[0] === "127.0.0.1" && spawnArgs[1] === "5002").toBe(true); | ||
} | ||
}); | ||
@@ -77,0 +79,0 @@ }); |
@@ -44,2 +44,33 @@ /** | ||
}); | ||
}); | ||
describe("OSC emit messages:", function() { | ||
var oscClass = require("../../src/server/osc.class.js"), | ||
OSC = new oscClass(); | ||
beforeEach(function(){ | ||
// Disable console messages | ||
OSC.debug = false; | ||
spyOn(OSC, "emit"); | ||
OSC.init(); | ||
}); | ||
afterEach(function(){ | ||
OSC.destroy(); | ||
}); | ||
it("should emit a ready message when the OSC module says it's ready.", function() { | ||
OSC.udpPort.emit("ready"); | ||
expect(OSC.emit).toHaveBeenCalledWith("ready"); | ||
}); | ||
it("should emit a message when receiving data.", function() { | ||
// This arraybuffer contains a /muse/eeg address | ||
// Caught from the actual muse data | ||
var arrayBuffer = new Uint8Array([0x2f, 0x6d, 0x75, 0x73, 0x65, 0x2f, 0x65, 0x65, 0x67, 0x00, 0x00, 0x00, 0x2c, 0x66, 0x66, 0x66, 0x66, 0x00, 0x00, 0x00, 0x44, 0xc5, 0x32, 0x28, 0x43, 0xd1, 0xbc, 0x29, 0x44, 0xa7, 0x95, 0x16, 0x43, 0xd1, 0xbc, 0x29]); | ||
OSC.udpPort.emit("data", arrayBuffer); | ||
expect(OSC.emit).toHaveBeenCalledWith("data", jasmine.objectContaining({address: "/muse/eeg"}), undefined, jasmine.any(Object)); | ||
}); | ||
}); |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2139949
45
2701
106
+ Added@serialport/binding-mock@10.2.2(transitive)
+ Added@serialport/bindings-cpp@12.0.1(transitive)
+ Added@serialport/bindings-interface@1.2.2(transitive)
+ Added@serialport/parser-byte-length@12.0.0(transitive)
+ Added@serialport/parser-cctalk@12.0.0(transitive)
+ Added@serialport/parser-delimiter@11.0.012.0.0(transitive)
+ Added@serialport/parser-inter-byte-timeout@12.0.0(transitive)
+ Added@serialport/parser-packet-length@12.0.0(transitive)
+ Added@serialport/parser-readline@11.0.012.0.0(transitive)
+ Added@serialport/parser-ready@12.0.0(transitive)
+ Added@serialport/parser-regex@12.0.0(transitive)
+ Added@serialport/parser-slip-encoder@12.0.0(transitive)
+ Added@serialport/parser-spacepacket@12.0.0(transitive)
+ Added@serialport/stream@12.0.0(transitive)
+ Addeddebug@4.3.4(transitive)
+ Addedlong@4.0.0(transitive)
+ Addedms@2.1.2(transitive)
+ Addednode-addon-api@7.0.0(transitive)
+ Addednode-gyp-build@4.6.0(transitive)
+ Addedosc@2.4.5(transitive)
+ Addedserialport@12.0.0(transitive)
+ Addedwolfy87-eventemitter@5.2.9(transitive)
+ Addedws@8.18.0(transitive)
- Removedasync@0.9.0(transitive)
- Removedbindings@1.2.1(transitive)
- Removedbuffer-dataview@0.0.2(transitive)
- Removedbufferutil@1.1.0(transitive)
- Removeddebug@2.6.9(transitive)
- Removedlong@2.2.5(transitive)
- Removedminimist@0.0.10(transitive)
- Removedms@2.0.0(transitive)
- Removednan@1.8.4(transitive)
- Removedoptimist@0.6.1(transitive)
- Removedoptions@0.0.6(transitive)
- Removedosc@1.4.0(transitive)
- Removedserialport@1.7.4(transitive)
- Removedsf@0.1.7(transitive)
- Removedultron@1.0.2(transitive)
- Removedutf-8-validate@1.1.0(transitive)
- Removedwordwrap@0.0.3(transitive)
- Removedws@0.7.2(transitive)
Updatedosc@^2.0.1