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 = ; const tcpLayer = '1.2.3.4';const logix5000 = tcpLayer; console; /** Read an element from a 1-dimensional tag */console; /** Read an entire 1-dimensional tag */console; /** Read the first 4 elements of a 1-dimensional tag */console /** * Read a slice of a 1-dimensional tag * example returns an array containing the values of elements 3 through 7 */console; /** Read an element of a structure member of a tag */console; /** * Read all tags scoped to a program * returns an object containing all of the scoped tags */console; /** Read a program scoped tag */console; /** * Read a tag using the symbol instance id * (available in controller version 21 and above) */console; /** List all global tags */for await const tag of logix5000 console; /** List all tags scoped to a program */for await const tag of logix5000 console; await tcpLayer;
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 = ; const tcpLayer = '1.2.3.4';const cipLayer = tcpLayer;const pccc = cipLayer; /** Write an integer */console; /** Read an integer */console; /** Write a float */console; await tcpLayer;
Find all EtherNet/IP devices in a subnet using the UDP broadcast address or by explicitly pinging each host:
const UDP CIP = ; const udpLayer = '1.2.3.255';const eipLayer = udpLayer; /** Broadcast */console; /** Explicitly */const hosts = ;for let i = 1; i < 255; i++ hosts; /* hosts overrides whatever host was specified in the Layers.UDP() constructor */console; await udpLayer;
Retrieve information from an EtherNet/IP device over TCP:
const TCP CIP = ; const tcpLayer = '1.2.3.4';const eipLayer = tcpLayer; console; console; /** no response, used to test underlying transport layer */await eipLayer; await tcpLayer;
Communicate with a Modbus device over TCP:
const TCP Modbus = ; const tcpLayer = '1.2.3.4';const modbusLayer = tcpLayer; // read holding register 40004console; await tcpLayer;
Drivers/Protocols
- CIP
- EtherNet/IP
- Logix5000
- PCCC
- embedded in CIP
- Modbus
- TCP frame format
- TCP
- UDP