ptrks / node-omron-fins Goto Github PK
View Code? Open in Web Editor NEWAn implementation of the Omron FINS library for node js
License: Apache License 2.0
An implementation of the Omron FINS library for node js
License: Apache License 2.0
Make header FINS transaction SID value accessible in message objects. This allows for tracking individual request / response pairs.
This is a problem of not validate the SID when returning information.
In my example, 2 nodes (10.20.100.254) have two query to the controller (Omron CJ2M) at the same time (frame 281, 282). For a reason (bug of the manufacturer) that I do not know, the two answers will come to the second node, because the PLC replaced the Dst Port (frame 283). Since it does not validate the SID ... it is that it causes bad data on the node.
Frame 281. Src Port 51123, Dst Port 9600, SID 0xbc, Query 50 Data, Sent by node 1
Frame 282. Src Port 33667, Dst Port 9600, SID 0Xbd, Query 10 Data, Sent by node 2
Frame 283. Src Port 9600, Dst Port 33667, SID 0Xbc, Answer 50 Data, Why PLC change Dst Port ??????????? I dont know ! But the node 2 was listening on this port
Frame 284. Src Port 9600, Dst Port 33667, SID 0Xbd, Answer 10 Data, OK !, Receive by node 2
The plc should not change the port, but ... node-omron-fins not valide de Service ID (SID)
Originally posted by @patbou74 in https://github.com/patrick--/node-omron-fins/issues/12#issuecomment-442228733
As of now, there is no bitwise (bit by bit) read/write functions available.
Reading a bit is not so important because we can read a word and use desired bit inside the word, that might be handled in the application.
But writing a bit
is a more complex operation (like database transactions) so it should be included/exposed by the library, possibly with a "dot notation" format:
client.write "C100.01", true/false
I tried to read data from memory area HR.
Googled around a bit and found HR to be 0x80.
I've updated the constants.js file to include HR area like this:
module.exports.MemoryAreas = {
'H' : 0x80,
'D' : 0x82
};
I've added a console.log(temp)
to fins_client.js' _translateMemoryAddress
function just to verify that MemoryArea is in fact set to 0x80.
I do a simple .read('H00300', 24)
and do a console.log(msg)
in the 'reply' event method:
{
remotehost: '10.0.0.233',
sid: 9,
command: '0101',
response: '0000',
values: [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
}
In Omron Sysmac Studio, we inspect the H3xx memory area and it dones not look like this. Values should be like [big integer, 0, 2, ...]
Any ideas?
To be able to track multiple parallel requests, I simply added:
return self.header.SID;
to FinsClient.prototype.read and FinsClient.prototype.write.
It is possible to have this patch in the code?
Thank you.
GT
Using the electron library when I run the application it gives me the following error:
(node:5664) UnhandledPromiseRejectionWarning: TypeError: Cannot set properties of undefined (setting 'mps')
(Use electron --trace-warnings ...
to show where the warning was created)
(node:5664) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict
(see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
The solution with which I solved this problem was to modify line 35 in the FinsSequenceManager.js file from
self.mpsCounter = this.mps = 0;
to
self.mpsCounter = 0;
There is no need for process.exit()
when value is outside of desired range. Simply throwing error is enough.
var fins = require('omron-fins');
var port = 9600, ip = '192.168.250.1', options = {timeout: 10000};
var client = fins.FinsClient(port, ip);
// This does not read correctly
setTimeout(function(){
client.read('D6029', 1);
}, 11000);
Results in this error:
/* The cases that do not read correctly give the following error
Missing error handler on `socket`.
Error: Not running
at Socket._healthCheck (dgram.js:420:11)
at Socket.send (dgram.js:272:8)
at FinsClient.run (/var/lib/cloud9/MPFTraceServer/node_modules/omron-fins/lib/fins_client.js:324:17)
at Socket.objCurrCycleTraceData.objProductionQty.SID (/var/lib/cloud9/MPFTraceServer/app_cycle.js:42:16)
at Socket.emit (events.js:95:17)
at Socket.onevent (/var/lib/cloud9/MPFTraceServer/node_modules/socket.io/lib/socket.js:330:8)
at Socket.onpacket (/var/lib/cloud9/MPFTraceServer/node_modules/socket.io/lib/socket.js:290:12)
at Client.ondecoded (/var/lib/cloud9/MPFTraceServer/node_modules/socket.io/lib/client.js:193:14)
at Decoder.Emitter.emit (/var/lib/cloud9/MPFTraceServer/node_modules/socket.io/node_modules/socket.io-parser/node_modules/component-emitter/index.js:134:20)
at Decoder.add (/var/lib/cloud9/MPFTraceServer/node_modules/socket.io/node_modules/socket.io-parser/index.js:247:12)
*/
Issue reported to me by RSampson.
Timeout value never changes from default value when options object is passed.
Hi,
thanks for sharing your work.
May I ask if and how is possible to write chars in a DM? What's the correct approach?
I know that I can store 2 chars per each DM, one in the MSB and one in the LSB.
Thanks
Noticed you haven't assigned a license for the project yet, from my experience it definitely gets more complicated over time as you have more contributors/copyright holders. Also, some people may not be able to contribute because of employer IP agreements if a license isn't assigned (I'm in this boat).
If you are going for open-source, Github's licensing site has good advice: https://opensource.guide/legal/, https://choosealicense.com/
Looking forward to contributing to the project!
I'm not sure if this is the rigth place for a question...
can anyone help me with using this wonderful library in a express api
const express = require('express');
const router = express.Router();
var fins = require('../lib/index');
var client = fins.FinsClient(9600, '172.16.103.125');//plc address
router.get('/', (req, res) => {
res.send('data from PLC');//here I'd like to send back to the client the values from the PLC
});
I'm also not sure if this is the rigth place for my question...
I'm a newbie with Raspberry pi and node red.
Please can anyone help me using this wonderful library in node-red?
Is it possible to read on multiple address?
For example:
.read(['D00000', 'D12345', 'D32145']);
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.