node-modbus
Advanced tools
Comparing version 3.0.0 to 3.0.1
@@ -8,3 +8,3 @@ /** | ||
var stampit = require('stampit') | ||
var Log = require('stampit-log') | ||
var log = require('stampit-log') | ||
var StateMachine = require('stampit-state-machine') | ||
@@ -27,3 +27,3 @@ | ||
.compose(StateMachine) | ||
.compose(Log) | ||
.compose(log) | ||
.init(function () { | ||
@@ -69,3 +69,3 @@ var responseHandler = { } | ||
this.emit('trashCurrentRequest') | ||
this.logError('Request timed out after ' + this.timeout / 1000 + ' sec') | ||
this.log.error('Request timed out after ' + this.timeout / 1000 + ' sec') | ||
this.emit('timeout') | ||
@@ -72,0 +72,0 @@ }.bind(this), this.timeout) |
@@ -9,6 +9,6 @@ /** | ||
var EventBus = require('stampit-event-bus') | ||
var Log = require('stampit-log') | ||
var log = require('stampit-log') | ||
var core = stampit() | ||
.compose(EventBus, Log) | ||
.compose(EventBus, log) | ||
.init(function () { | ||
@@ -41,2 +41,4 @@ var coils | ||
this.onData = function (pdu, callback) { | ||
this.log.debug('incoming data') | ||
// get fc and byteCount in advance | ||
@@ -43,0 +45,0 @@ var fc = pdu.readUInt8(0) |
@@ -53,3 +53,8 @@ /** | ||
socket.connect(this.port, this.host) | ||
try { | ||
socket.connect(this.port, this.host) | ||
this.log.debug('socket connected') | ||
} catch (err) { | ||
this.log.error(err + ' on socket connect') | ||
} | ||
}.bind(this) | ||
@@ -71,3 +76,2 @@ | ||
reconnect = false | ||
connect() | ||
@@ -92,3 +96,2 @@ }, this.reconnectTimeout || 0) | ||
// 1. extract mbap | ||
var id = buffer.readUInt16BE(0) | ||
@@ -122,4 +125,3 @@ var len = buffer.readUInt16BE(4) | ||
var onError = function () { | ||
this.logError('Client in error state.') | ||
this.log.error('Client in error state.') | ||
socket.destroy() | ||
@@ -176,7 +178,4 @@ }.bind(this) | ||
closedOnPurpose = true | ||
this.log.debug('Closing client on purpose.') | ||
socket.end() | ||
return this | ||
@@ -183,0 +182,0 @@ } |
@@ -7,6 +7,4 @@ /** | ||
var stampit = require('stampit') | ||
var logger = require('stampit-log') | ||
module.exports = stampit() | ||
.compose(logger) | ||
.init(function () { | ||
@@ -17,2 +15,3 @@ let buffer = Buffer.alloc(0) | ||
if (!this.socket || this.socketId === undefined || !this.onRequest) { | ||
this.log.error('socket:' + this.socket + ' socketId:' + this.socketId + 'onRequest' + this.onRequest) | ||
throw new Error('No Socket defined.') | ||
@@ -72,3 +71,3 @@ } | ||
this.onSocketError = function (e) { | ||
this.logError('Socker error', e) | ||
this.log.error('Socker error', e) | ||
}.bind(this) | ||
@@ -75,0 +74,0 @@ |
@@ -36,21 +36,26 @@ /** | ||
server.on('connection', function (s) { | ||
this.log.debug('new connection', s.address()) | ||
server.on('connection', function (socket) { | ||
this.log.debug('new connection', socket.address()) | ||
clients.push(s) | ||
initiateSocket(s) | ||
clients.push(socket) | ||
initiateSocket(socket) | ||
}.bind(this)) | ||
server.listen(this.port, this.hostname, function (err) { | ||
if (err) { | ||
this.log.debug('error while listening', err) | ||
this.emit('error', err) | ||
} | ||
}.bind(this)) | ||
try { | ||
server.listen(this.port, this.hostname, function (err) { | ||
if (err) { | ||
this.log.debug('error while listening', err) | ||
this.emit('error', err) | ||
} | ||
}.bind(this)) | ||
this.log.debug('server is listening on port', this.hostname + ':' + this.port) | ||
this.log.debug('server is listening on port', this.hostname + ':' + this.port) | ||
this.on('newState_ready', flush) | ||
this.on('newState_ready', flush) | ||
this.setState('ready') | ||
} catch (err) { | ||
this.log.error('server is listening error ' + err + ' on port', this.hostname + ':' + this.port) | ||
this.setState('error') | ||
} | ||
this.setState('ready') | ||
}.bind(this) | ||
@@ -111,3 +116,2 @@ | ||
} | ||
socketList.splice(i, 1) | ||
@@ -114,0 +118,0 @@ } |
@@ -9,2 +9,3 @@ /** | ||
var path = require('path') | ||
var ModbusCore = require('./modbus-client-core.js') | ||
@@ -22,6 +23,3 @@ var ModbusTcpClient = require('./modbus-tcp-client.js') | ||
}, | ||
handler: { | ||
} | ||
handler: {} | ||
} | ||
@@ -43,3 +41,3 @@ | ||
}, | ||
handler: { } | ||
handler: {} | ||
} | ||
@@ -46,0 +44,0 @@ |
{ | ||
"name": "node-modbus", | ||
"version": "3.0.0", | ||
"version": "3.0.1", | ||
"description": "Sum of implementations for the Serial/TCP Modbus protocol.", | ||
@@ -14,2 +14,3 @@ "author": "Klaus Landsdorf <klaus.landsdorf@bianco-royal.de>", | ||
"crc": "^3.4.4", | ||
"net": "^1.0.2", | ||
"serialport": "^4.0.7", | ||
@@ -16,0 +17,0 @@ "stampit": "^2.1.2", |
@@ -8,3 +8,3 @@ [![NPM download](https://img.shields.io/npm/dm/node-modbus.svg)](http://www.npm-stats.com/~packages/node-modbus) [![NPM version](https://badge.fury.io/js/node-modbus.png)](http://badge.fury.io/js/node-modbus) | ||
[![Build Status](https://travis-ci.org/biancode/node-modbus-1.svg?branch=master)](https://travis-ci.org/biancode/node-modbus-1) | ||
[![Build Status](https://travis-ci.org/biancode/node-modbus.svg?branch=master)](https://travis-ci.org/biancode/node-modbus) | ||
[![Standard - JavaScript Style Guide](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com/) | ||
@@ -11,0 +11,0 @@ |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
80047
1601
2
8
+ Addednet@^1.0.2
+ Addednet@1.0.2(transitive)