mathiask88 / node-snap7

node.js wrapper for snap7
MIT License
166 stars 59 forks source link

Can't trigger Q1/Q2 #70

Open stephanmae opened 4 years ago

stephanmae commented 4 years ago

Hi there, I am trying to connect to S7 and open the Q1 on a logo. Therefore, I am writing one bit which should trigger the Q1 to open. But it does not work, connection succeedes, writing even succeeds, but the relais does not get closed:

Does anyone has an idea?

var snap7 = require('node-snap7');

var s7client = new snap7.S7Client(); s7client.ConnectTo('192.168.1.2', 0, 2, function(err) { if(err) return console.log(' >> Connection failed. Code #' + err + ' - ' + s7client.ErrorText(err));

// Read the first byte from PLC process outputs...
console.log('reading q1');
var read = s7client.ABRead(1, 1);
console.log(read);

// open
console.log('writing q1');
const buffer = new Buffer([0x01]);
var result = s7client.ABWrite(1, 1, buffer, function(err) {
    if(err)
        return console.log(' >> ABRead failed. Code #' + err + ' - ' + s7client.ErrorText(err));
    console.log(err);
});

console.log(result); });

Many thanks!