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

jsmewtocol

v0.0.7

Published

Panasonic PLC MEWTOCOL COM protocol TCP implementation for Node.JS

Downloads

32

Readme

node-mewtocol

Panasonic MEWTOCOL COM protocol implementation for Node-JS

Please use official MEWTOCOL manual as a reference: MEWTOCOL.pdf At the moment only some read commands are implemented:

  • RD(station,memory-area,start-addr,end-addr) - Read Registers
  • RCS(station,memory-area,address) - Read single Contact binary value
  • RCC(station,memory-area,start-addr,end-addr) - Read Contact values as 16bit integers
  • RCP(station,addresses-array) - Read up to 8 Contact binary values in a single request
  • RS(station,start-addr,end-addr) - Read timer set values
  • RK(station,start-addr,end-addr) - Read timer elapsed values
  • RR(station,start-addr,end-addr) - Read system register
  • RT(station) - Read PLC status

Install

Run the following command in the root directory of your Node.JS application:

npm install jsmewtocol

Run the following command for global install:

npm install -g jsmewtocol

Usage:

const MewClient = require('jsmewtocol');
var ip=10.10.10.11 // ip address of the PLC
var port=9094; // TCP port is optional, default is 9094
var timeout=5000; // timeout is optional, default is 5000ms

const client = new MewClient(ip,port,timeout);
client.on('connect', (server) => { console.log('Event: connected to server: '+server.host+":"+server.port); });
client.on('disconnect', (err) => { console.log('Event: disconnected '+err); }); //the err for disconnect is true if there was an error before disconnecting
client.on('error', (err) => { console.log('Event: error: ' + err.error); }); //err object will contain error details
client.on('timeout', (err) => { console.log('Event: timeout: ' + err.error); }); //err object will contain timeout reason

//If we want to consecutively read different values from the PLC we can use Promises .then construction:
client.RD(1,'D',800,809) // first let's read registers from area D, addresses 800-809 (10 values)
.then ((data)=>{console.log(data); return client.RCS(1,'X','50A');}) // then let's read single bit from Contact area X at address 50, bit #10 (0xA)
.then ((data)=>{console.log(data); return client.RCC(1,'X',100,109);})// then read 16bit Contact values from area X from addresses 100-109 (10 values)
.then ((data)=>{console.log(data); return client.RT(1);}) // then read PLC status
.then ((data)=>{console.log(data); return client.destroy();}) // we need to destroy the connection after we are done reading, otherwise it will wait until socket timeout
.catch ((err) =>{ console.error(err); client.destroy();}); // catch any errors

It is important to destroy the client socket. Otherwise it will hang until PLC drops the connection on it's end or socket timeout will happen. If the socket is destroyed due to timeout, the node-mewtocol will try to re-establish the connection