node-ethernet-ip
node-ethernet-ip copied to clipboard
Improvement for scan_rate
Using ethernet-ip in Node-RED, I did some analysis of the realtime behaviour using Wireshark. There I have seen the real scan rate (320 ms) does not match the setup in the project (200 ms). Before the scan rate set up as the time delay between the last resonse of the PLC and the next request. In case of longer tag list (up to 30 tags), there are two tag groups exchanged. Now there is a timer used that triggers the start of the request more precise.
Description, Motivation, and Context
The use of "delay" does no provide a scan_rate who meets the value setup, even if the tag list is longer as e.g. 30 tags.
How Has This Been Tested?
PLC: CompactLogix L32E Host 1: PC with Windows 10 and Node.js 12.16.2 (x64) Host 2: Raspberry PI with Raspian and Node-RED v1.0.5 Ethernet packet captured with Wireshark.
Screenshots (if appropriate):
Types of changes
- [x] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to change)
Checklist:
- [x] My code follows the code style of this project.
- [ ] My change requires a change to the documentation.
- [ ] I have updated the documentation accordingly.
- [x] I have read the CONTRIBUTING document.
- [x] I have added tests to cover my changes.
- [x] All new and existing tests passed.
- [ ] This is a work in progress, and I want some feedback (If yes, please mark it in the title -> e.g.
[WIP] Some awesome PR title
)
Related Issue
scan_rate designed to create a safe delay between the scan requests. Also setting an interval on external communications is bad practice. On a poor network it can end up with number of sent requests without responses. Also if I have 1000 tags to scan then request/response time might take longer that setInterval
delay which will cause sending another request of 1000 tags without receiving response for the first batch.
Also timer
variable is created locally. What if I want to pause the scan out of the scan
method.
If you need to get the responses faster, I would suggest just to reduce the delay: the scan_rate
.