{"id":19938766,"url":"https://github.com/raphaelbs/modbus-event","last_synced_at":"2025-10-05T16:27:25.461Z","repository":{"id":57300345,"uuid":"65855199","full_name":"raphaelbs/modbus-event","owner":"raphaelbs","description":"Modbus-event is a TCP/IP Master, event-driven, NodeJS implementation for modbus protocol.","archived":false,"fork":false,"pushed_at":"2017-05-24T15:08:59.000Z","size":7,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-17T21:02:56.438Z","etag":null,"topics":["event-driven-architecture","modbus","modbus-protocol","modbus-serial","nodejs-modules"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/raphaelbs.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}},"created_at":"2016-08-16T21:34:17.000Z","updated_at":"2020-07-13T00:21:33.000Z","dependencies_parsed_at":"2022-09-08T16:41:58.518Z","dependency_job_id":null,"html_url":"https://github.com/raphaelbs/modbus-event","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raphaelbs%2Fmodbus-event","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raphaelbs%2Fmodbus-event/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raphaelbs%2Fmodbus-event/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raphaelbs%2Fmodbus-event/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/raphaelbs","download_url":"https://codeload.github.com/raphaelbs/modbus-event/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252203362,"owners_count":21710950,"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":["event-driven-architecture","modbus","modbus-protocol","modbus-serial","nodejs-modules"],"created_at":"2024-11-12T23:41:54.738Z","updated_at":"2025-10-05T16:27:20.413Z","avatar_url":"https://github.com/raphaelbs.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# modbus-event\n\nModbus-event is a TCP/IP Master, event-driven, implementation for modbus protocol.\nThis package was built upon the great [modbus-serial](https://www.npmjs.com/package/modbus-serial).\nMake sure to read the [methods](https://www.npmjs.com/package/modbus-serial#methods) section to get the best out this module.\n\n## Installation\n\n```bash\nnpm i -S modbus-event\n```\n\n## Usage\n\n```javascript\n// Require library\nvar modbusEvent = require('modbus-event');\n// Set constructor options\nvar options = {\n    debug : true, // default: false\n    ip : '192.168.1.1', // default: '127.0.0.1'\n    port : 777, // default: 502\n    id : 2 // default: 1\n};\nvar me = modbusEvent(options);\n\n// Executes some function in between the reading stage\nme.run(function(client, datas, next){\n    client.writeCoil(1, 1).then(next);\n});\n\n// Assign a listener event\nme.on('update', function(type, address, newValue, oldValue){\n    console.log(type, address, newValue, oldValue);\n});\n```\n\n## Reference\n\n#### require('modbus-event')\n\u003e_return Function([options](#constructor-object-argument-options))_\n\nMain function of [modbus-event](https://www.npmjs.com/package/modbus-event)\n\n#### Constructor argument: Options\n\nkey | description | type | default\n--- | --- | --- | ---\n*debug* | Enable verbosity for debuggin (very handy) | boolean | false\n*ip* | The listenning IP of your Slave Modbus | string | '127.0.0.1'\n*port* | The listenning port of yout Slave Modbus | number | 502\n*id* | The SlaveID of your Slave Modbus | number | 1\n*address* | Reading address range | _Object_ { init : _initial address_, length : _address range_ } | { init : 0, length : 10 }\n\n##### Sample:\n\n```javascript\nvar options = {\n    debug : true, // default: false\n    ip : '192.168.1.1', // default: '127.0.0.1'\n    port : 777, // default: 502\n    id : 2 // default: 1\n};\nvar me = modbusEvent(options);\n```\n\n#### require('modbus-event')(options)\n\u003e_return Object { run : fn, on : fn }_\n\nThe constructor of [modbus-event](https://www.npmjs.com/package/modbus-event).\nReturn the following functions:\n\nkey | value\n--- | ---\n_run_ | function(client, data, next)\n_on_ | function(event, callback)\n\n#### require('modbus-event')(options)#run\n\u003e_type Function(client, data, next)_\n\nExecutes arbitrary code when the serial channel is available. The function arguments are:\n\nargument | description\n--- | ---\n_client_ | an instance of [modbus-serial](https://www.npmjs.com/package/modbus-serial)\n_data_ | object containing all addresses and values\n_next_ | a function that you **need to invoke** when done\n\n#### require('modbus-event')(options)#on\n\u003e_type Function(event, callback)_\n\nAssign an event and the respective callback. This are the available events:\n\nupdate | function(type, address, newValue, oldValue)\n--- | ---\ntriggers when **any** register is changed | **type** is the address indentifier ('coils', 'inputStatus', 'holdingReg', 'inputReg')\n\u0026nbsp; | **address** is the changed address in the moment\n\u0026nbsp; | **newValue** is the value before the update\n\u0026nbsp; | **oldValue** is the value after the update\n\n## Dependencies\n\n[modbus-serial](https://www.npmjs.com/package/modbus-serial)\n\n## Contact-me\n* [Email](mailto:raphael.b.souza@hotmail.com)\n* [Facebook](https://facebook.com/raphaelbs)\n* [GitHub](https://github.com/raphaelbs)\n* [NPM](https://npmjs.com/~raphaelbs)\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fraphaelbs%2Fmodbus-event","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fraphaelbs%2Fmodbus-event","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fraphaelbs%2Fmodbus-event/lists"}