s7client-ts
TypeScript icon, indicating that this package has built-in type declarations

0.0.3 • Public • Published

S7Client-ts

Typescript port of S7Client, the Hi-Level API for node-snap7 to communicate with Siemens S7 PCLs (See compatibility).

  • Typescript
  • Promise based, async/await support
  • Returns javascript objects with parsed var objects
  • EventEmitter: (connect, disconnect, connect_error, value)
  • Optional auto reconnect

Api Documentation

// TODO

Usage

npm install s7client-ts
import { S7Client, S7DbVarAreaDbRead } from 's7client-ts';

// PLC Connection Settings
const plcSettings = {
  name: "LocalPLC",
  host: 'localhost',
  port: 9102,
  rack: 0,
  slot: 2
};


// DBA to read
const dbNr = 102;
const dbVars: S7DbVarAreaDbRead[] = [
  // { type: "CHAR", start: 0 },
  { type: "BOOL", start: 4, bit: 2 },
  { type: 'INT', start: 13 }
];

const client = new S7Client(plcSettings);
client.on('error', console.error);

(async function () {
  console.log("connectind");
  await client.connect().catch((e) => console.log(e));
  console.log("connected", client.isConnected());

  // Read DB
  const res: S7DbVarAreaDbRead[] = await client.readDB(dbNr, dbVars);
  console.log(res);

  // Write multiple Vars
  await client.writeVars([{
    area: 'db', dbnr: 1, type: 'BOOL',
    start: 5, bit: 2,
    value: true
  }]);

  client.disconnect();
})();

Special thanks to

  • Davide Nardella for creating snap7
  • Mathias Küsel for creating node-snap7
  • Christoph Wiechert for creating s7client

License & copyright

Readme

Keywords

Package Sidebar

Install

npm i s7client-ts

Weekly Downloads

0

Version

0.0.3

License

MIT

Unpacked Size

48.6 kB

Total Files

9

Last publish

Collaborators

  • caciuto