2.0.2 • Published 4 years ago

node-drivers v2.0.2

Weekly downloads
12
License
MIT
Repository
github
Last release
4 years ago

node-drivers

A layered approach to protocol drivers.

Install

npm install node-drivers

Examples

Read and list tags from a Logix5000 processor:

const { TCP, CIP } = require('node-drivers');

const tcpLayer = new TCP('1.2.3.4');
const logix5000 = new CIP.Logix5000(tcpLayer);

console.log(await logix5000.readTag('tagname'));

/** Read an element from a 1-dimensional tag */
console.log(await logix5000.readTag('TagThatIs1DArray[0]'));

/** Read an entire 1-dimensional tag */
console.log(await logix5000.readTag('TagThatIs1DArray'));

/** Read the first 4 elements of a 1-dimensional tag */
console.log(await logix5000.readTag('TagThatIs1DArray', 4))

/**
 * Read a slice of a 1-dimensional tag
 * example returns an array containing the values of elements 3 through 7
 */
console.log(await logix5000.readTag('TagThatIs1DArray[3]', 5));

/** Read an element of a structure member of a tag */
console.log(await logix5000.readTag('tag.member[0].anothermember'));

/**
 * Read all tags scoped to a program
 * returns an object containing all of the scoped tags
 */
console.log(await logix5000.readTag('TheProgramName'));

/** Read a program scoped tag */
console.log(await logix5000.readTag('TheProgramName.tag'));

/**
 * Read a tag using the symbol instance id
 * (available in controller version 21 and above)
 */
console.log(await logix5000.readTag(2130));

/** List all global tags */
for await (const tag of logix5000.listTags()) {
  console.log(tag);
}

/** List all tags scoped to a program */
for await (const tag of logix5000.listTags('Program:Alarms')) {
  console.log(tag);
}

await tcpLayer.close();

Read/Write a tag from a PLC-5, SLC 5/03, or SLC 5/04 processor using PCCC embedded in CIP:

const { TCP, CIP, PCCC } = require('node-drivers');

const tcpLayer = new TCP('1.2.3.4');
const cipLayer = new CIP(tcpLayer);
const pccc = new PCCC(cipLayer);

/** Write an integer */
console.log(await pccc.typedWrite('N10:47', 1000));

/** Read an integer */
console.log(await pccc.typedRead('N10:47'));

/** Write a float */
console.log(await pccc.typedWrite('F8:1', 5.5));

await tcpLayer.close();

Find all EtherNet/IP devices in a subnet using the UDP broadcast address or by explicitly pinging each host:

const { UDP, CIP } = require('node-drivers');

const udpLayer = new UDP('1.2.3.255');
const eipLayer = new CIP.EIP(udpLayer);

/** Broadcast */
console.log(await eipLayer.listIdentity());


/** Explicitly */
const hosts = [];
for (let i = 1; i < 255; i++) {
  hosts.push(`1.2.3.${i}`);
}

/* hosts overrides whatever host was specified in the Layers.UDP() constructor */
console.log(await eipLayer.listIdentity({ hosts }));

await udpLayer.close();

Retrieve information from an EtherNet/IP device over TCP:

const { TCP, CIP } = require('node-drivers');

const tcpLayer = new TCP('1.2.3.4');
const eipLayer = new CIP.EIP(tcpLayer);

console.log(await eipLayer.listInterfaces());

console.log(await eipLayer.listServices());

/** no response, used to test underlying transport layer */
await eipLayer.nop();

await tcpLayer.close();

Communicate with a Modbus device over TCP:

const { TCP, Modbus } = require('node-drivers');

const tcpLayer = new TCP('1.2.3.4');
const modbusLayer = new Modbus(tcpLayer);

// read holding register 40004
console.log(await modbusLayer.readHoldingRegisters(3, 1));

await tcpLayer.close();

Drivers/Protocols

  • CIP
    • EtherNet/IP
    • Logix5000
  • PCCC
    • embedded in CIP
  • Modbus
    • TCP frame format
  • TCP
  • UDP
2.0.2

4 years ago

2.0.1

4 years ago

2.0.0

4 years ago

2.0.0-beta.9

4 years ago

2.0.0-beta.8

4 years ago

2.0.0-beta.7

4 years ago

2.0.0-beta.6

4 years ago

2.0.0-beta.5

4 years ago

2.0.0-beta.4

4 years ago

2.0.0-beta.3

4 years ago

2.0.0-beta.2

4 years ago

2.0.0-beta.1

4 years ago

2.0.0-beta.0

4 years ago

1.5.4

5 years ago

1.5.3

5 years ago

1.5.2

5 years ago

1.5.1

5 years ago

1.5.0

5 years ago

1.4.1

5 years ago

1.4.0

5 years ago

1.3.4

5 years ago

1.3.3

5 years ago

1.3.2

5 years ago

1.3.1

5 years ago

1.3.0

5 years ago

1.2.10

5 years ago

1.2.9

5 years ago

1.2.8

5 years ago

1.2.7

5 years ago

1.2.6

5 years ago

1.2.5

5 years ago

1.2.4

5 years ago

1.2.3

5 years ago

1.2.2

5 years ago

1.2.1

5 years ago

1.2.0

5 years ago

1.1.2

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.32

5 years ago

1.0.31

5 years ago

1.0.30

5 years ago

1.0.29

5 years ago

1.0.28

5 years ago

1.0.27

5 years ago

1.0.26

5 years ago

1.0.25

5 years ago

1.0.24

6 years ago

1.0.23

6 years ago

1.0.22

6 years ago

1.0.21

7 years ago

1.0.20

7 years ago

1.0.19

7 years ago

1.0.18

7 years ago

1.0.17

7 years ago

1.0.16

7 years ago

1.0.15

7 years ago

1.0.14

7 years ago

1.0.13

7 years ago

1.0.12

7 years ago

1.0.11

7 years ago

1.0.10

7 years ago

1.0.9

7 years ago

1.0.8

7 years ago

1.0.7

7 years ago

1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago