{"id":16382885,"url":"https://github.com/dresende/node-modbus-tcp","last_synced_at":"2025-04-10T01:08:11.173Z","repository":{"id":12350862,"uuid":"14996045","full_name":"dresende/node-modbus-tcp","owner":"dresende","description":"NodeJS Modbus TCP/IP","archived":false,"fork":false,"pushed_at":"2018-07-09T16:40:27.000Z","size":54,"stargazers_count":118,"open_issues_count":0,"forks_count":48,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-04-10T01:08:06.733Z","etag":null,"topics":["modbus","modbus-tcp","tcp"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dresende.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-12-06T23:23:14.000Z","updated_at":"2024-10-27T13:50:36.000Z","dependencies_parsed_at":"2022-09-26T18:30:28.194Z","dependency_job_id":null,"html_url":"https://github.com/dresende/node-modbus-tcp","commit_stats":null,"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dresende%2Fnode-modbus-tcp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dresende%2Fnode-modbus-tcp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dresende%2Fnode-modbus-tcp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dresende%2Fnode-modbus-tcp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dresende","download_url":"https://codeload.github.com/dresende/node-modbus-tcp/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248137887,"owners_count":21053775,"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":["modbus","modbus-tcp","tcp"],"created_at":"2024-10-11T04:06:45.684Z","updated_at":"2025-04-10T01:08:11.155Z","avatar_url":"https://github.com/dresende.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Modbus TCP/IP Stream\n\n[![Build Status](https://secure.travis-ci.org/dresende/node-modbus-tcp.png?branch=master)](http://travis-ci.org/dresende/node-modbus-tcp)\n\nThis is a very simple module that uses NodeJS Streams2 to read Modbus TCP data and convert it to JSON and vice-versa.\n\n## Install\n\nIf you're just starting or just trying to use this library, **I advise you to try [modbus-stream](http://github.com/node-modbus/stream)**. It's more complete (it supports all standard function codes) and it was designed to work with TCP, RTU and ASCII modes.\n\n```sh\nnpm install modbus-tcp\n```\n\n## Example\n\n```js\nvar modbus = require(\"modbus-tcp\");\nvar client = new modbus.Client();\nvar server = new modbus.Server();\n\n// link client and server streams together\nclient.writer().pipe(server.reader());\nserver.writer().pipe(client.reader());\n// if you have a socket (stream) you can just\n// call client.pipe(socket) or server.pipe(socket)\n\nserver.on(\"read-coils\", function (from, to, reply) {\n    return reply(null, [ 1, 0, 1, 1 ]);\n});\n\n// read coils from unit id = 0, from address 10 to 13\nclient.readCoils(0, 10, 13, function (err, coils) {\n    // coils = [ 1, 0, 1, 1 ]\n});\n```\n\n## Client Methods\n\nAll of the following read methods have the form `method(unitId, from, to, next)` and write methods have the form `method(unitId, addr, val, next)`, where `next` is an **optional** function called if the server replies (with the same transactionId) to the sent message.\n\n- readCoils\n- readDiscreteInputs\n- readHoldingRegisters\n- readInputRegisters\n- writeSingleCoil\n- writeSingleRegister\n- writeMultipleCoils\n- writeMultipleRegisters\n\nAddresses are exactly as is in protocol, so if you see a paper talking about address `40001` this usually means first record address of that function so it means address `0`.\n\n## Server Events\n\n- read-coils\n- read-discrete-inputs\n- read-holding-registers\n- read-input-registers\n- write-single-coil\n- write-single-register\n- write-multiple-coils\n- write-multiple-registers\n- data\n\nThis last event is triggered when an unknown function code is received.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdresende%2Fnode-modbus-tcp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdresende%2Fnode-modbus-tcp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdresende%2Fnode-modbus-tcp/lists"}