Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

nodes7

Package Overview
Dependencies
Maintainers
1
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nodes7 - npm Package Compare versions

Comparing version 0.3.1 to 0.3.2

testCHANGELOG.md

5

CHANGELOG.md

@@ -0,1 +1,6 @@

Version: 0.3.2
------------
- Fix bug related to bit array length (thanks to luisbardalez)
- Better tracking of timers during dropConnection (thanks to gfcittolin)
Version: 0.3.1

@@ -2,0 +7,0 @@ ------------

16

package.json
{
"name": "nodes7",
"description": "Routine to communicate with Siemens S7 PLCs",
"version": "0.3.1",
"version": "0.3.2",
"author": {
"name": "Dana Moffit",
"email": "nodejsplc@gmail.com"
"name": "Dana Moffit",
"email": "nodejsplc@gmail.com"
},
"keywords": [
"S7",
"Siemens",
"PLC",
"RFC1006",
"iso-on-tcp"
"S7",
"Siemens",
"PLC",
"RFC1006",
"iso-on-tcp"
],

@@ -16,0 +16,0 @@ "repository": {

nodeS7
======
NodeS7 is a library that allows communication to S7-300/400/1200/1500 PLCs using the Siemens S7 Ethernet protocol RFC1006.
NodeS7 is a library that allows communication to S7-300/400/1200/1500 PLCs using the Siemens S7 Ethernet protocol RFC1006.
This software is not affiliated with Siemens in any way, nor am I. S7-300, S7-400, S7-1200 and S7-1500 are trademarks of Siemens AG.
WARNING - This is ALPHA CODE and you need to be aware that WRONG VALUES could be written to WRONG LOCATIONS. Fully test everything you do. In situations where writing to a random area of memory within the PLC could cost you money, back up your data and test this really well. If this could injure someone or worse, consider other software.
WARNING
=======
This is ALPHA CODE and you need to be aware that WRONG VALUES could be written to WRONG LOCATIONS. Fully test everything you do. In situations where writing to a random area of memory within the PLC could cost you money, back up your data and test this really well. If this could injure someone or worse, consider other software.
It is optimized in three ways - It sorts a large number of items being requested from the PLC and decides what overall data areas to request, then it groups multiple small requests together in a single packet or number of packets up to the maximum length the PLC supports, then it sends multiple packets at once, for maximum speed. So a request for 100 different bits, all close (but not necessarily completely contiguous) will be grouped in one single request to the PLC, with no additional direction from the user.
Installation
=======
Using npm:
* `npm install nodes7`
NodeS7 manages reconnects for you. So if the connection is lost because the PLC is powered down or disconnected, you can continue to request data with no other action necessary. "Bad" values are returned, and eventually the connection will be automatically restored.
Using yarn:
* `yarn add nodes7`
NodeS7 is written entirely in Javascript, so no compiler installation is necessary on Windows, and deployment on other platforms (ARM, etc) should be no problem.
Optimization
=======
S7-1200 and S7-1500 CPU access requires access using "Slot 1" and you must disable optimized block access (in TIA portal) for the blocks you are using. In addition, you must "Enable GET/PUT Access" in the 1500 controller in TIA Portal. Doing so opens up the controller for other access by other applications as well, so be aware of the security implications of doing this.
* It is optimized in three ways - It sorts a large number of items being requested from the PLC and decides what overall data areas to request, then it groups multiple small requests together in a single packet or number of packets up to the maximum length the PLC supports, then it sends multiple packets at once, for maximum speed. So a request for 100 different bits, all close (but not necessarily completely contiguous) will be grouped in one single request to the PLC, with no additional direction from the user.
This has been tested only on direct connection to newer PROFINET CPUs and Helmholz NetLINK PRO COMPACT units. It SHOULD work with any CP that supports TCP as well, but S7-200/400/1200 haven't been tested. Very old CPUs have not been tested. S7 routing is not supported.
* NodeS7 manages reconnects for you. So if the connection is lost because the PLC is powered down or disconnected, you can continue to request data with no other action necessary. "Bad" values are returned, and eventually the connection will be automatically restored.
* NodeS7 is written entirely in Javascript, so no compiler installation is necessary on Windows, and deployment on other platforms (ARM, etc) should be no problem.
PLC Support
=======
* S7-1200 and S7-1500 CPU access requires access using "Slot 1" and you must disable optimized block access (in TIA portal) for the blocks you are using. In addition, you must "Enable GET/PUT Access" in the 1500 controller in TIA Portal. Doing so opens up the controller for other access by other applications as well, so be aware of the security implications of doing this.
* This has been tested only on direct connection to newer PROFINET CPUs and Helmholz NetLINK PRO COMPACT units. It SHOULD work with any CP that supports TCP as well, but S7-200/400/1200 haven't been tested. Very old CPUs have not been tested. S7 routing is not supported.
Credit to the S7 Wireshark dissector plugin for help understanding why things were not working.
(http://sourceforge.net/projects/s7commwireshark/)
To get started:
Examples
======
npm install nodes7
Example usage:
var nodes7 = require('nodes7'); // This is the package name, if the repository is cloned you may need to require 'nodeS7' with uppercase S

@@ -41,3 +53,3 @@ var conn = new nodes7;

TEST7: 'DB1,INT12.2' // Two integer value array
};
};

@@ -49,3 +61,3 @@ conn.initiateConnection({port: 102, host: '192.168.0.2', rack: 0, slot: 1}, connected); // slot 2 for 300/400, slot 1 for 1200/1500

if (typeof(err) !== "undefined") {
// We have an error. Maybe the PLC is not reachable.
// We have an error. Maybe the PLC is not reachable.
console.log(err);

@@ -55,8 +67,8 @@ process.exit();

conn.setTranslationCB(function(tag) {return variables[tag];}); // This sets the "translation" to allow us to work with object names
conn.addItems(['TEST1', 'TEST4']);
conn.addItems(['TEST1', 'TEST4']);
conn.addItems('TEST6');
// conn.removeItems(['TEST2', 'TEST3']); // We could do this.
// conn.writeItems(['TEST5', 'TEST6'], [ 867.5309, 9 ], valuesWritten); // You can write an array of items as well.
conn.writeItems('TEST7', [ 666, 777 ], valuesWritten); // You can write a single array item too.
conn.readAllItems(valuesReady);
// conn.removeItems(['TEST2', 'TEST3']); // We could do this.
// conn.writeItems(['TEST5', 'TEST6'], [ 867.5309, 9 ], valuesWritten); // You can write an array of items as well.
conn.writeItems('TEST7', [ 666, 777 ], valuesWritten); // You can write a single array item too.
conn.readAllItems(valuesReady);
}

@@ -78,5 +90,4 @@

### API
API
=====
- [initiateConnection()](#initiate-connection)

@@ -91,23 +102,41 @@ - [dropConnection()](#drop-connection)

#### <a name="initiate-connection"></a>nodes7.initiateConnection(params, callback)
Connects to a PLC.
## <a name="initiate-connection"></a>nodes7.initiateConnection(options, callback)
#### Description
Connects to a PLC.
params should be an object with the following keys:
- rack (default 0)
- slot (default 2)
- port (normally specify 102)
- host (address)
#### Arguments
`callback(err)` will be executed on success or failure. err is either an error object, or undefined on successful connection.
`Options`
|Property|type|default|
| --- | --- | --- |
| rack | number | 0 |
| slot | number | 2 |
| port | number | 102 |
| host | string | 192.168.8.106 |
| timeout | number | 5000 |
| localTSAP | hex | undefined |
| remoteTSAP | hex | undefined |
#### <a name="drop-connection"></a>nodes7.dropConnection(callback)
Disconnects from a PLC.
`callback(err)`
<dl>
<dt>err</dt>
<dd>
err is either an error object, or undefined on successful connection.
</dd>
</dl>
This simply terminates the TCP connection. The callback is called upon completion of the close.
## <a name="drop-connection"></a>nodes7.dropConnection(callback)
#### Description
Disconnects from a PLC. This simply terminates the TCP connection.
#### Arguments
`callback()`
#### <a name="set-translation-cb"></a>nodes7.setTranslationCB(translator)
Sets a callback for name - address translation.
The callback is called upon completion of the close.
## <a name="set-translation-cb"></a>nodes7.setTranslationCB(translator)
#### Description
Sets a callback for name - address translation.
This is optional - you can choose to use "addItem" etc with absolute addresses.

@@ -118,3 +147,3 @@

Examples:
#### Examples:
- MR30 - MD30 as REAL

@@ -129,8 +158,10 @@ - DB10,INT6 - DB10.DBW6 as INT

In the example above, an object is declared and the `translator` references that object. It could just as reference a file or database. In any case, it allows cleaner Javascript code to be written that refers to a name instead of an absolute address.
In the example above, an object is declared and the `translator` references that object. It could just as reference a file or database. In any case, it allows cleaner Javascript code to be written that refers to a name instead of an absolute address.
## <a name="add-items"></a>nodes7.addItems(items)
#### Description
Adds `items` to the internal read polling list.
#### <a name="add-items"></a>nodes7.addItems(items)
Adds `items` to the internal read polling list.
#### Arguments
`items` can be a string or an array of strings.

@@ -140,5 +171,7 @@

#### <a name="remove-items"></a>nodes7.removeItems(items)
Removes `items` to the internal read polling list.
## <a name="remove-items"></a>nodes7.removeItems(items)
#### Description
Removes `items` to the internal read polling list.
#### Arguments
`items` can be a string or an array of strings.

@@ -148,14 +181,34 @@

#### <a name="write-items"></a>nodes7.writeItems(items, values)
Writes `items` to the PLC using the corresponding `values`.
## <a name="write-items"></a>nodes7.writeItems(items, values, callback)
#### Description
Writes `items` to the PLC using the corresponding `values` and calls `callback` when done.
`items` can be a string or an array of strings. If `items` is a single string, `values` should then be a single item (or an array if `items` is an array item). If `items` is an array of strings, `values` must be an array.
You should monitor the return value - if it is non-zero, the write will not be processed as there is already one it progress, and the callback will not be called.
#### Arguments
`items` can be a string or an array of strings.
#### <a name="read-all-items"></a>nodes7.readAllItems(callback)
Reads the internal polling list and calls `callback` when done.
If `items` is a single string, `values` should then be a single item.
`callback(err, values)` is called with two arguments - a boolean indicating if ANY of the items have "bad quality", and `values`, an object containing the values being read as keys and their value (from the PLC) as the value.
If `items` is an array of strings, `values` must also be an array of values.
`callback(err)`
<dl>
<dt>err</dt>
<dd>a boolean indicating if ANY of the items have "bad quality".</dd>
</dl>
## <a name="read-all-items"></a>nodes7.readAllItems(callback)
#### Description
Reads the internal polling list and calls `callback` when done.
#### Arguments
`callback(err, values)`
<dl>
<dt>err</dt>
<dd>a boolean indicating if ANY of the items have "bad quality".</dd>
<dt>values</dt>
<dd>an object containing the values being read as keys and their value (from the PLC) as the value.</dd>
</dl>

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc