node.js wrapper for snap7
Switch branches/tags
Nothing to show
Clone or download
mathiask88 Fix appveyor
Appveyor log ''node' is not recognized as an internal or external command'
Latest commit 46337fc Nov 19, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
deps/snap7
doc
lib fix node v4's inconsistent/bad inherits(...) behavior Jan 18, 2018
src fix DBGet arguments Nov 18, 2018
.gitignore
.npmignore fixed typo Jul 8, 2015
.travis.yml test on node 11 Nov 11, 2018
LICENSE Updates copyright year to 2018 Jan 1, 2018
README.md Updates copyright year to 2018 Jan 1, 2018
appveyor.yml Fix appveyor Nov 19, 2018
binding.gyp
package.json

README.md

node-snap7

Build Status Build status dependencies Status

Current node-snap7 version: 1.0.0
Current snap7 version: 1.4.2

About

This is a node.js wrapper for snap7. Snap7 is an open source, 32/64 bit, multi-platform Ethernet communication suite for interfacing natively with Siemens S7 PLCs (See compatibility).

Installation

Install with:

npm install node-snap7

node-snap7 uses prebuild and prebuild-install for handling prebuilt binaries. See this list of supported prebuilt platform binaries. When installing node-snap7 prebuild-install will install prebuilt binaries from GitHub if they exist and fallback to a compile step if they don't.

If you don't want to use the prebuild for the platform you are installing on, specify the --build-from-source flag when you install.

For building from source you need the following requirements:

Special thanks to

  • Davide Nardella for creating snap7

How to use

API

Client Example

var snap7 = require('node-snap7');

var s7client = new snap7.S7Client();
s7client.ConnectTo('192.168.1.12', 0, 1, function(err) {
    if(err)
        return console.log(' >> Connection failed. Code #' + err + ' - ' + s7client.ErrorText(err));

    // Read the first byte from PLC process outputs...
    s7client.ABRead(0, 1, function(err, res) {
        if(err)
            return console.log(' >> ABRead failed. Code #' + err + ' - ' + s7client.ErrorText(err));

        // ... and write it to stdout
        console.log(res)
    });
});

Server Example

var snap7 = require('node-snap7');

var s7server = new snap7.S7Server();

// Set up event listener
s7server.on("event", function(event) {
    console.log(s7server.EventText(event));
});

// Create a new Buffer and register it to the server as DB1
var db1 = new Buffer(100).fill('ÿ');
s7server.RegisterArea(s7server.srvAreaDB, 1, db1);

// Start the server
s7server.StartTo('127.0.0.1');

// Close the server after 20s in this example
setTimeout(function() {
    s7server.Stop();
    s7server.UnregisterArea(s7server.srvAreaDB, 1);
}, 20000);

Have a look at the resourceless server example here.

License & copyright

Copyright (c) 2018, Mathias Küsel

node-snap7 is licensed under the MIT license. All rights not explicitly granted in the MIT license are reserved. See the included LICENSE file for more details.

node-snap7 builds on the excellent work of the snap7 framework from Davide Nardella. Snap7 is issued under the GPL/LGPLv3 (see ./deps/snap7/gpl.txt ./deps/snap7/lgpl-3.0.txt).