s7client-ts
v0.0.3
Published
Step7 client based on node-step7 and inspired by s7client, Typescript ready
Downloads
9
Readme
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
- S7Client-ts: MIT
- S7Client: MIT
- node-snap7: MIT
- snap7: LGPLv3