How to use modbus-serial - 2 common examples

To help you get started, we’ve selected a few modbus-serial examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github kubeedge / kubeedge / mappers / modbus_mapper / sample / sample_server.js View on Github external
// Asynchronous handling supported also here
        console.log("set register", addr, value, unitID);
        holdingValue = value;
    setCoil: function(addr, value, unitID) {
        // Asynchronous handling supported also here
        console.log("set coil", addr, value, unitID);
        coilValue = Boolean(value);

// set the server to answer for modbus requests
console.log("ModbusTCP listening on modbus://");
var serverTCP = new ModbusRTU.ServerTCP(vector, { host: "", port: 5028, debug: true, unitID: 1 });

serverTCP.on("socketError", function(err){
    // Handle socket error if needed, can be ignored
github BiancoRoyal / node-red-contrib-modbus / src / modbus-flex-server.js View on Github external
node.startServer = function () {
      try {
        if (node.modbusServer === null) {
          try {
            node.modbusServer = new ModbusRTU.ServerTCP(node.vector, {
              host: node.serverAddress,
              port: node.serverPort,
              debug: node.logEnabled,
              unitID: node.unitId
          } catch (err) {
            node.error(err, { payload: 'server net error -> for port 502 on unix, you have to be a super user' })

          node.modbusServer.on('socketError', function (err) {
            if (node.showErrors) {
            mbBasics.setNodeStatusTo('error', node)


A pure JavaScript implemetation of MODBUS-RTU (Serial and TCP) for NodeJS.

Latest version published 2 months ago

Package Health Score

75 / 100
Full package analysis

Popular modbus-serial functions

Popular JavaScript code snippets

Find secure code to use in your application or website