npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

mpi-s7

v0.4.1

Published

Node.JS library to communicate with MPI-USB adapters

Downloads

22,030

Readme

mpi-s7

This library aims to implement all the protocols needed to communicate with MPI-USB adapters, used to communicate with some older PLCs from Siemens. It does not implement the "S7 communication" protocol, leaving it to other libraries.

This software is not affiliated with Siemens in any way, nor am I. S7-300, S7-400, S7-1200 and S7-1500 are trademarks of Siemens AG.

This node was created as part of the ST-One project.

Disclaimer

This is a work in progress. Expect things to break, crash and burn. We cannot be hold liable for any damage to any equipment or issues directly or indirectly caused by this library. You've been warned.

Install

This library depends on the node-usb library, therefore their requirements apply here. Apart from that, you can currently install it by running

npm install mpi-s7

Linux

Two main topics can cause you problem on Linux: Permissions and ModemManager. To avoid them, you can copy the udev rule 90-mpi-usb.rules that is on the root folder of this project to /etc/udev/rules.d, and reload them with udevadm control --reload(or just restart your system).

The udev rule will:

  • Put the MPI-USB adapter on the dialout group, where most users already are
  • Set a flag that instructs ModemManager to ignore the adapter

Feel free to adjust the rule to your needs

Windows

On Windows, you'll need to use Zadig to install a libusb-compatible driver to the MPI-USB adapter. After installing it, the adapter should be accessible from this library, but won't be accessible from other software anymore.

Usage

Warning: this library currenlty offers a modified version of the nodes7 interface as a shortcut for the implementation of the upper "S7 communication" protocol. In the near future the efforts will be merged with them, and we'll no longer offer it anymore. Expect a complete new API to interact with.

const mpiS7 = require('.');

let conn = new mpiS7.NodeS7();

const variables = {
    TEST1: 'M0.7'
}

const opts = {
    mpiAddress: 6
}

function readAllItems() {
    conn.readAllItems((err, data) => {
        if (err) {
            console.log("Error reading values!", err);
        } else {
            console.log("Values:", data);
        }

        //don't forget to close connection before exiting!
        conn.dropConnection();
    })
}

conn.initiateConnection(opts, err => {
    if (err) {
        console.log("Error connecting to PLC!", err)
        return;
    }

    console.log("Connected to the PLC!");

    conn.setTranslationCB(tag => variables[tag]);
    conn.addItems(Object.keys(variables));

    readAllItems();
});

Documentation

TODOs

Besides all //TODOs on the code, we have:

  • [ ] PPP - resend data if we don't get an ACK
  • [ ] PPP - implement max retries if don't get an ack

License

Copyright: (c) 2019-2021, ST-One, Guilherme Francescon Cittolin [email protected]

GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)