devicestack
Advanced tools
Comparing version 1.9.3 to 1.9.4
@@ -243,2 +243,12 @@ var EventEmitter2 = require('eventemitter2').EventEmitter2, | ||
/** | ||
* Dequeue task | ||
* @param {Task} cmd The task that should be dequeued. | ||
*/ | ||
Connection.prototype.dequeueTask = function(task) { | ||
this.taskQueue = _.reject(this.taskQueue, function(t) { | ||
return t.task === task; | ||
}); | ||
}; | ||
/** | ||
* Executes the passing command. | ||
@@ -265,4 +275,9 @@ * If the initialize function is present it will validate the arguments of the command. | ||
} catch (err) { | ||
if (self.log) self.log('Error while sending command: ' + command.constructor.name + '!'); | ||
if (callback) { callback(new Error('Error while sending command: ' + command.constructor.name + '!')); } | ||
var addon = ''; | ||
if (err.message) { | ||
addon = ' > ' + err.message; | ||
} | ||
if (self.log) self.log(err.name + ' while sending command: ' + command.constructor.name + '!' + addon); | ||
self.dequeueCommand(command); | ||
throw err; | ||
} | ||
@@ -285,4 +300,9 @@ }); | ||
} catch (err) { | ||
if (this.log) this.log(err.name + ' while executing command: ' + command.constructor.name + '!'); | ||
if (callback) { callback(err); } | ||
var addon = ''; | ||
if (err.message) { | ||
addon = ' > ' + err.message; | ||
} | ||
if (this.log) this.log(err.name + ' while executing command: ' + command.constructor.name + '!' + addon); | ||
this.dequeueCommand(command); | ||
throw err; | ||
} | ||
@@ -400,4 +420,9 @@ }; | ||
} catch (err) { | ||
if (this.log) this.log(err.name + ' while executing task: ' + task.constructor.name + '!'); | ||
if (callback) { callback(err); } | ||
var addon = ''; | ||
if (err.message) { | ||
addon = ' > ' + err.message; | ||
} | ||
if (this.log) this.log(err.name + ' while executing task: ' + task.constructor.name + '!' + addon); | ||
this.dequeueTask(task); | ||
throw err; | ||
} | ||
@@ -415,2 +440,9 @@ | ||
Connection.prototype.copy = function(device) { | ||
var clone = new Connection(device || this.device); | ||
clone.set(this.attributes); | ||
clone.set('id', clone.id); | ||
return clone; | ||
}; | ||
module.exports = Connection; |
@@ -133,2 +133,12 @@ var EventEmitter2 = require('eventemitter2').EventEmitter2, | ||
Device.prototype.copy = function() { | ||
var clone = new Device(this.Connection); | ||
if (this.connection) { | ||
clone.connection = this.connection.copy(this); | ||
} | ||
clone.set(this.attributes); | ||
clone.set('id', clone.id); | ||
return clone; | ||
}; | ||
module.exports = Device; |
@@ -82,14 +82,20 @@ var EventEmitter2 = require('eventemitter2').EventEmitter2, | ||
if (this.incomming.length === 0) return; | ||
try { | ||
if (this.incomming.length === 0) return; | ||
var nextFrame; | ||
while ((nextFrame = this.analyzeNextFrame(this.incomming)) && nextFrame.length) { | ||
if (this.unwrapFrame) { | ||
var unwrappedFrame = this.unwrapFrame(_.clone(nextFrame)); | ||
if (this.log) this.log('receive unwrapped frame: ' + unwrappedFrame.toHexDebug()); | ||
this.emit('receive', unwrappedFrame); | ||
} else { | ||
if (this.log) this.log('receive frame: ' + nextFrame.toHexDebug()); | ||
this.emit('receive', nextFrame); | ||
var nextFrame; | ||
while ((nextFrame = this.analyzeNextFrame(this.incomming)) && nextFrame.length) { | ||
if (this.unwrapFrame) { | ||
var unwrappedFrame = this.unwrapFrame(_.clone(nextFrame)); | ||
if (this.log) this.log('receive unwrapped frame: ' + unwrappedFrame.toHexDebug()); | ||
this.emit('receive', unwrappedFrame); | ||
} else { | ||
if (this.log) this.log('receive frame: ' + nextFrame.toHexDebug()); | ||
this.emit('receive', nextFrame); | ||
} | ||
} | ||
} catch(err) { | ||
this.isAnalyzing = false; | ||
this.trigger(); | ||
throw err; | ||
} | ||
@@ -96,0 +102,0 @@ }; |
{ | ||
"name": "devicestack", | ||
"version": "1.9.3", | ||
"version": "1.9.4", | ||
"description": "This module helps you to represent a device and its protocol.", | ||
@@ -23,3 +23,3 @@ "private": false, | ||
"optionalDependencies": { | ||
"serialport": ">=1.2.2", | ||
"serialport": ">=1.2.3", | ||
"ftdi": ">=1.0.3", | ||
@@ -26,0 +26,0 @@ "usb-detection": ">=1.0.3", |
@@ -405,2 +405,6 @@ <pre> | ||
###BE SURE TO DEFINE JSON SCHEMAS! | ||
Hint: [http://jsonary.com/documentation/json-schema/](http://jsonary.com/documentation/json-schema/) | ||
## tasks | ||
@@ -447,2 +451,6 @@ Build your own tasks looking like this: | ||
###BE SURE TO DEFINE JSON SCHEMAS! | ||
Hint: [http://jsonary.com/documentation/json-schema/](http://jsonary.com/documentation/json-schema/) | ||
## utils | ||
@@ -449,0 +457,0 @@ Some utility functions are shipped with this module. |
@@ -0,11 +1,12 @@ | ||
## v1.9.4 | ||
- do not call callback twice if error is throwing on consumer callback | ||
- stabilize frame handler | ||
## v1.9.3 | ||
- removed postinstall script for optionalDependencies | ||
## v1.9.2 | ||
- added postinstall script for optionalDependencies | ||
## v1.9.1 | ||
- delete connection if not needed anymore | ||
@@ -15,7 +16,5 @@ - better errors for example if calling connect twice | ||
## v1.9.0 | ||
- implemented optional arguments validation by JSON schema for commands and tasks | ||
## v1.8.7 | ||
- impemented has function for Device and Connection | ||
@@ -26,47 +25,35 @@ - Warning! initialize function now passes connection as first argument and after that all other arguments passed by the constructor! | ||
## v1.8.6 | ||
- Connection: moved function isByteArray to Array.isByteArray | ||
## v1.8.5 | ||
- Connection: added function isByteArray | ||
## v1.8.4 | ||
- print some error messages | ||
## v1.8.3 | ||
- connection: added dequeueCommand function | ||
## v1.8.2 | ||
- The Enum type is not included automatically in devicestack. Please use it directly from [enum](https://github.com/adrai/enum). | ||
## v1.8.1 | ||
- connection: try to better catch errors while sending commands | ||
## v1.8.0 | ||
- introduce connectionStateChanged on DeviceGuider | ||
## v1.7.0 | ||
- introduce command and task validation (initialize function) | ||
## v1.6.4 | ||
- updated dependencies | ||
## v1.6.3 | ||
- DeviceGuider now emits connecting and disconnecting events | ||
## v1.6.2 | ||
- added possibility to add multiple vid/pid pairs | ||
## v1.6.1 | ||
- SerialDeviceLoader compare devices by lowercase port name | ||
@@ -76,3 +63,2 @@ - emit error on device only if there are listeners | ||
## v1.6.0 | ||
- implemented EventedSerialDeviceLoader (for USB devices that virtualizes the COM port) | ||
@@ -82,3 +68,2 @@ - fix for SerialDeviceLoader (bug was only for non-global users) | ||
## v1.5.1 | ||
- optimization for hibernate/sleep/standby | ||
@@ -89,3 +74,2 @@ | ||
## v1.5.0 | ||
- ftdi integration | ||
@@ -99,3 +83,2 @@ | ||
## v1.4.0 | ||
- default serial device loaders uses the global serial device loader under the hood |
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
116618
2434
930