Code Monkey home page Code Monkey logo

s7client's Introduction

S7Client

npm Dependencies Known Vulnerabilities Greenkeeper badge Maintainability Test Coverage Donate

clone of the awesome work of https://github.com/psi-4ward/s7client with small changes for connecting to sinamics drives.

Hi-Level API for node-snap7 to communicate with Siemens S7 PCLs (See compatibility).

  • Promise based, async/await support
  • Returns javascript objects with parsed var objects
  • EventEmitter: (connect, disconnect, connect_error, value)
  • Optional auto reconnect

API Documentation

Blog post about my SIMATIC S7 Web HMI project.

Usage

npm install s7client
const {S7Client} = require('s7client');

// PLC Connection Settings
const plcSettings = {
  name: "LocalPLC",
  host: 'localhost',
  port: 9102,
  rack: 0,
  slot: 2
};

// DBA to read
let dbNr = 1;
let dbVars = [
  { type: "CHAR", start: 0 },
  { type: "BOOL", start: 2, bit: 0 },
  { type: 'INT', start: 3 }
];

let client = new S7Client(plcSettings);
client.on('error', console.error);

(async function() {
  await client.connect();

  // Read DB
  const res = await client.readDB(dbNr, dbVars);
  console.log(res);

  // Write multiple Vars
  await client.writeVars([{
    area: 'db', dbnr: 1, type: 'BOOL',
    start: 5, bit: 2,
    value: true
  }]);

  client.disconnect();
})();

Special thanks to

  • Davide Nardella for creating snap7
  • Mathias Küsel for creating node-snap7

License & copyright

s7client's People

Contributors

rv1989 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.