{"id":17477593,"url":"https://github.com/cloud-automation/node-modbus","last_synced_at":"2025-10-05T07:49:17.726Z","repository":{"id":15483053,"uuid":"18216678","full_name":"Cloud-Automation/node-modbus","owner":"Cloud-Automation","description":"Modbus TCP Client/Server implementation for Node.JS","archived":false,"fork":false,"pushed_at":"2024-09-19T13:02:00.000Z","size":845,"stargazers_count":480,"open_issues_count":15,"forks_count":180,"subscribers_count":35,"default_branch":"v4.0-dev","last_synced_at":"2025-05-13T08:02:39.142Z","etag":null,"topics":["javascript","modbus","modbus-tcp","nodejs","rtu-client","serial-ports","tcp-client"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Cloud-Automation.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-03-28T15:24:29.000Z","updated_at":"2025-05-03T19:56:17.000Z","dependencies_parsed_at":"2024-11-20T23:44:29.666Z","dependency_job_id":"1281f687-7960-4ac7-ba5a-473c92987bd9","html_url":"https://github.com/Cloud-Automation/node-modbus","commit_stats":{"total_commits":353,"total_committers":29,"mean_commits":"12.172413793103448","dds":0.5779036827195467,"last_synced_commit":"4f80e1baf9a50dd9c1436852cc8871552b180911"},"previous_names":[],"tags_count":42,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cloud-Automation%2Fnode-modbus","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cloud-Automation%2Fnode-modbus/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cloud-Automation%2Fnode-modbus/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cloud-Automation%2Fnode-modbus/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Cloud-Automation","download_url":"https://codeload.github.com/Cloud-Automation/node-modbus/tar.gz/refs/heads/v4.0-dev","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254301432,"owners_count":22047904,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["javascript","modbus","modbus-tcp","nodejs","rtu-client","serial-ports","tcp-client"],"created_at":"2024-10-18T20:08:21.778Z","updated_at":"2025-10-05T07:49:12.707Z","avatar_url":"https://github.com/Cloud-Automation.png","language":"TypeScript","readme":"A simple an easy to use Modbus TCP client/server implementation.\n\n[![JavaScript Style Guide](https://cdn.rawgit.com/feross/standard/master/badge.svg)](https://github.com/feross/standard)\n\nModbus [![Build Status](https://travis-ci.org/Cloud-Automation/node-modbus.png)](https://travis-ci.org/Cloud-Automation/node-modbus)\n========\n\nModbus is a simple Modbus TCP/RTU Client/Server with a simple API. It supports modbus function codes 1 - 6 and 15 and 16.\n\nStatus\n------\n\nVersion 4.0.0 is a early beta release. Please use and test it and help make it better. We keep you posted on the status of this module.\n\nInstallation\n------------\n\nJust type `npm install jsmodbus` and you are ready to go. You can also install this module globally and use the Command Line Interface. Simply type `npm install -g jsmodbus`.\n\nCLI\n---\n\nVersion 4 offers a Command Line Interface. Just install the module globally and type `jsmodbus --help` to get some more Information.\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\nDebugging\n---------\nIf you want to see some debugging information, since Version 3 we use the debug module. You can filter the debug output by defining the DEBUG environment variable like so `export DEBUG=*`\n\nTCP Client Example\n--------------\n```javascript\n// create a tcp modbus client\nconst Modbus = require('jsmodbus')\nconst net = require('net')\nconst socket = new net.Socket()\nconst client = new Modbus.client.TCP(socket, unitId)\nconst options = {\n'host' : host,\n'port' : port\n}\n\n```\n\nRTU Client Example\n---------------------\n```javascript\n\n// create a tcp modbus client\nconst Modbus = require('jsmodbus')\nconst SerialPort = require('serialport')\nconst options = {\nbaudRate: 57600\n}\nconst socket = new SerialPort(\"/dev/tty-usbserial1\", options)\nconst client = new Modbus.client.RTU(socket, address)\n```\n\nClient API Example\n------------------\n```javascript\n// for reconnecting see node-net-reconnect npm module\n\n// use socket.on('open', ...) when using serialport\nsocket.on('connect', function () {\n\n// make some calls\n\nclient.readCoils(0, 13).then(function (resp) {\n\n// resp will look like { response : [TCP|RTU]Response, request: [TCP|RTU]Request }\n// the data will be located in resp.response.body.coils: \u003cArray\u003e, resp.response.body.payload: \u003cBuffer\u003e\n\nconsole.log(resp);\n\n}, console.error);\n\n});\n\nsocket.connect(options)\n\n```\n\nKeeping TCP Connections alive\n----------------------------\nI've written a module to keep net.Socket connections alive by emitting TCP Keep-Alive messages. Have a look at the node-net-reconnect module.\n\nServer example\n--------------\n```javascript\n\nconst modbus = require('jsmodbus')\nconst net = require('net')\nconst netServer = new net.Server()\nconst server = new modbus.server.TCP(netServer)\n\nnetServer.listen(502)\n\n````\n\n\n## License (MIT)\n\nCopyright (C) 2017 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","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcloud-automation%2Fnode-modbus","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcloud-automation%2Fnode-modbus","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcloud-automation%2Fnode-modbus/lists"}