Im trying to use this to communicate with a iQ-F plc FX5UC. I cannot seem to get it to return any informaiton from the PLC. It states it connects ok but then all the values returned are BAD 255. I am using the sample code but have commented out all the Tests except Test 2 and set it to only read M0-M15
`import mc from 'mcprotocol';
var conn = new mc;
var doneReading = false;
var doneWriting = false;
var variables = {
TEST2: 'M0,16', // 16 bits Starting at M0 (M0-M15)
};
conn.initiateConnection({port: 1250, host: '192.168.3.250', ascii: false}, connected);
function connected(err) {
if (typeof(err) !== "undefined") {
// We have an error. Maybe the PLC is not reachable.
console.log(err);
process.exit();
}
conn.setTranslationCB(function(tag) {return variables[tag];}); // This sets the "translation" to allow us to work with object names defined in our app not in the module
conn.addItems(['TEST2']);
conn.readAllItems(valuesReady);
}
function valuesReady(anythingBad, values) {
if (anythingBad) { console.log("SOMETHING WENT WRONG READING VALUES!!!!"); }
console.log(values);
doneReading = true;
if (doneWriting) { process.exit(); }
}
function valuesWritten(anythingBad) {
if (anythingBad) { console.log("SOMETHING WENT WRONG WRITING VALUES!!!!"); }
console.log("Done writing.");
doneWriting = true;
if (doneReading) { process.exit(); }
}`
The responce I get [525821,69071600] Initiate Called - Connecting to PLC with address and parameters:
mcprotocol.js:1234
[525821,69847000] { port: 1250, host: '192.168.3.250', ascii: false }
mcprotocol.js:1234
[525821,70405800] Connection cleanup is happening
mcprotocol.js:1234
[525821,71757800 192.168.3.250] Attempting to connect to host...
mcprotocol.js:1234
[525821,75067000 192.168.3.250] TCP Connection Established to 192.168.3.250 on port 1250
mcprotocol.js:1234
[525821,75850400] Translation OK
mcprotocol.js:1234
[525821,76619900 192.168.3.250] Adding TEST2
mcprotocol.js:1234
[525825,580196400 192.168.3.250] READ TIMEOUT on sequence number 2
mcprotocol.js:1234
SOMETHING WENT WRONG READING VALUES!!!!
MCprotocol.js:26
{TEST2: 'BAD 255'}
Im trying to use this to communicate with a iQ-F plc FX5UC. I cannot seem to get it to return any informaiton from the PLC. It states it connects ok but then all the values returned are BAD 255. I am using the sample code but have commented out all the Tests except Test 2 and set it to only read M0-M15
`import mc from 'mcprotocol';
var conn = new mc;
var doneReading = false;
var doneWriting = false;
var variables = {
TEST2: 'M0,16', // 16 bits Starting at M0 (M0-M15)
};
conn.initiateConnection({port: 1250, host: '192.168.3.250', ascii: false}, connected);
function connected(err) {
if (typeof(err) !== "undefined") {
// We have an error. Maybe the PLC is not reachable.
console.log(err);
process.exit();
}
conn.setTranslationCB(function(tag) {return variables[tag];}); // This sets the "translation" to allow us to work with object names defined in our app not in the module
conn.addItems(['TEST2']);
}
function valuesReady(anythingBad, values) {
if (anythingBad) { console.log("SOMETHING WENT WRONG READING VALUES!!!!"); }
console.log(values);
doneReading = true;
if (doneWriting) { process.exit(); }
}
function valuesWritten(anythingBad) {
if (anythingBad) { console.log("SOMETHING WENT WRONG WRITING VALUES!!!!"); }
console.log("Done writing.");
doneWriting = true;
if (doneReading) { process.exit(); }
}`
The responce I get [525821,69071600] Initiate Called - Connecting to PLC with address and parameters:
mcprotocol.js:1234
[525821,69847000] { port: 1250, host: '192.168.3.250', ascii: false }
mcprotocol.js:1234
[525821,70405800] Connection cleanup is happening
mcprotocol.js:1234
[525821,71757800 192.168.3.250] Attempting to connect to host...
mcprotocol.js:1234
[525821,75067000 192.168.3.250] TCP Connection Established to 192.168.3.250 on port 1250
mcprotocol.js:1234
[525821,75850400] Translation OK
mcprotocol.js:1234
[525821,76619900 192.168.3.250] Adding TEST2
mcprotocol.js:1234
[525825,580196400 192.168.3.250] READ TIMEOUT on sequence number 2
mcprotocol.js:1234
SOMETHING WENT WRONG READING VALUES!!!!
MCprotocol.js:26
{TEST2: 'BAD 255'}