{"_id":"@aquanomix/symodbus","_rev":"6-0c7ac33d8d7d10e1d746bf47f70b355d","name":"@aquanomix/symodbus","time":{"modified":"2022-06-12T14:46:59.441Z","created":"2016-08-16T12:19:02.542Z","1.0.1":"2016-08-16T12:19:02.542Z","1.0.2":"2016-08-16T12:28:41.754Z","1.0.3":"2016-08-16T12:41:42.762Z"},"maintainers":[{"name":"0dj0bz","email":"rob@perceival.com"}],"dist-tags":{"symodbus":"1.0.3","latest":"1.0.3"},"versions":{"1.0.3":{"name":"@aquanomix/symodbus","version":"1.0.3","description":"Symphony Modbus Driver","author":{"name":"Rob Abbott","email":"rabbott@aquanomix.com"},"main":"./src/modbus.js","repository":{"type":"git","url":"https://github.com/0dj0bz/node-modbus"},"dependencies":{"put":"0.0.6","q":"1.0.1","serialport":"^3.0.0","stampit":"^2.1.1","stampit-event-bus":"^0.1.1","stampit-log":"^0.3.0","stampit-state-machine":"^0.2.1"},"devDependencies":{"sinon":"1.5.0"},"scripts":{"test":"mocha test/*"},"engine":{"node":">=0.6"},"license":"MIT","keywords":["client","server","serial","port","modbus","tcp"],"directories":{"example":"examples","test":"test"},"bugs":{"url":"https://github.com/0dj0bz/node-modbus/issues"},"homepage":"https://github.com/0dj0bz/node-modbus","gitHead":"5e6eef42cd497fabfbe6e45c06614963dacf9460","_id":"@aquanomix/symodbus@1.0.3","_shasum":"b9387b74929d6df086c0d55266f7986e22a0cf5d","_from":".","_npmVersion":"2.15.8","_nodeVersion":"4.4.7","_npmUser":{"name":"0dj0bz","email":"rob@perceival.com"},"dist":{"shasum":"b9387b74929d6df086c0d55266f7986e22a0cf5d","tarball":"https://registry.npmjs.org/@aquanomix/symodbus/-/symodbus-1.0.3.tgz","integrity":"sha512-X45/NUz8X932hjn3dVVOYeIoTjBsy0S4t6PjiSZVKdzE8v3yWj8jdnUpUcDbfbWRB8dGqwneTvcZLRICE0hbYg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQC/Yvnwkov/n77K8dsZWvQ5Y6rsEOZi02cxNKtyuao2FgIhALmiv1mG7N5R1JROoNtHQYUES3hfDMNGqOcgJde89R/x"}]},"maintainers":[{"name":"0dj0bz","email":"rob@perceival.com"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/symodbus-1.0.3.tgz_1471351301005_0.9361136462539434"}}},"description":"Symphony Modbus Driver","homepage":"https://github.com/0dj0bz/node-modbus","keywords":["client","server","serial","port","modbus","tcp"],"repository":{"type":"git","url":"https://github.com/0dj0bz/node-modbus"},"author":{"name":"Rob Abbott","email":"rabbott@aquanomix.com"},"bugs":{"url":"https://github.com/0dj0bz/node-modbus/issues"},"license":"MIT","readme":"A simple an easy to use Modbus TCP client/server implementation.\n\nThis is a fork of jsmodbus, written by Stefan Poeter.  Functionality within has been adapted to function with Aquanomix Symphony software and may not be suitable for other implementations.\n\nModbus\n========\n\nModbus is a simple Modbus TCP Client with a simple API.\n\nInstallation\n------------\n\nJust type `npm install symodbus` and you are ready to go.\n\nTesting\n-------\n\nThe test files are implemented using [mocha](https://github.com/visionmedia/mocha) and sinon.\n\nSimply `npm install -g mocha` and `npm install -g sinon`. To run the tests type from the projects root folder `mocha test/*`.\n\nPlease feel free to fork and add your own tests.\n\nTCP Client example\n--------------\n```javascript\nvar modbus = require('symodbus');\n\n// create a modbus client\nvar client = modbus.client.tcp.complete({ \n        'host'              : host, \n        'port'              : port,\n        'autoReconnect'     : true,\n        'reconnectTimeout'  : 1000,\n        'timeout'           : 5000,\n        'unitId'            : 0\n    });\n\nclient.connect();\n\n// reconnect with client.reconnect()\n\nclient.on('connect', function () {\n\n    // make some calls\n\n    client.readCoils(0, 13).then(function (resp) {\n\n        // resp will look like { fc: 1, byteCount: 20, coils: [ values 0 - 13 ] } \n        console.log(resp);\n\n    }).fail(console.log);\n\n    client.readDiscreteInput(0, 13).then(function (resp) {\n\n        // resp will look like { fc: 2, byteCount: 20, coils: [ values 0 - 13 ] } \n        console.log(resp);\n\n    }).fail(console.log);\n\n    client.readHoldingRegisters(0, 10).then(function (resp) {\n\n        // resp will look like { fc: 3, byteCount: 20, register: [ values 0 - 10 ] }\n        console.log(resp); \n\n    }).fail(console.log);\n\n    client.readInputRegister(0, 10).then(function (resp) {\n\n\t    // resp will look like { fc: 4, byteCount: 20, register: [ values 0 - 10 ] }\n\t    console.log(resp);\n\n    }).fail(console.log);\n\n    client.writeSingleCoil(5, true).then(function (resp) {\n\n\t    // resp will look like { fc: 5, byteCount: 4, outputAddress: 5, outputValue: true }\n\t    console.log(resp);\n\n    }).fail(console.log);\n\n    client.writeSingleRegister(13, 42).then(function (resp) {\n\n\t    // resp will look like { fc: 6, byteCount: 4, registerAddress: 13, registerValue: 42 }\n\t    console.log(resp);\n\n    }).fail(console.log);\n\n    client.writeMultipleCoils(3, [1, 0, 1, 0, 1, 1]).then(function (resp) {\n\n        // resp will look like { fc: 15, startAddress: 3, quantity: 6 }\n        console.log(resp); \n\n    }).fail(console.log);\n\n    client.writeMultipleRegisters(4, [1, 2, 3, 4]).then(function (resp) {\n        \n        // resp will look like { fc : 16, startAddress: 4, quantity: 4 }\n        console.log(resp);\n        \n    }).fail(console.log);\n\n});\n\nclient.on('error', function (err) {\n\n    console.log(err);\n    \n})\n```\n\nServer example\n--------------\n```javascript\n    \n    var stampit = require('stampit'),\n        modbus = require('jsmodbus');\n\n    var customServer = stampit()\n        .refs({\n            'logEnabled'        : true,\n            'port'              : 8888,\n            'responseDelay'     : 10, // so we do not fry anything when someone is polling this server\n\n            // specify coils, holding and input register here as buffer or leave it for them to be new Buffer(1024)\n            coils               : new Buffer(1024),\n            holding             : new Buffer(1024),\n            input               : new Buffer(1024)\n        })\n        .compose(modbus.server.tcp.complete)\n        .init(function () {\n        \n            var init = function () {\n\n                // get the coils with this.getCoils() [ Buffer(1024) ]\n                // get the holding register with this.getHolding() [ Buffer(1024) ]\n                // get the input register with this.getInput() [ Buffer(1024) ]                \n              \n                // listen to requests \n\n                this.on('readCoilsRequest', function (start, quantity) {\n                \n                    // do something, this will be executed in sync before the \n                    // read coils request is executed \n                    \n                });\n\n                // the write request have pre and post listener\n                this.on('[pre][post]WriteSingleCoilRequest', function (address, value) {\n                    \n                    \n                });\n\n            }.bind(this);    \n            \n            \n            init();\n            \n        });\n\n    customServer();\n\n    // you can of course always use a standard server like so\n\n    var server = modbus.server.tcp.complete({ port : 8888 });\n\n    // and interact with the register via the getCoils(), getHolding() and getInput() calls\n\n    server.getHolding().writeUInt16BE(123, 1);\n````\n\n## License\n\nCopyright (C) 2016 Rob Abbott (rabbott@aquanomix.com)\nPortions Copyright (C) 2016 Stefan Poeter (Stefan.Poeter[at]cloud-automation.de)\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","readmeFilename":"README.md"}