roccomuso / node-ads

NodeJS Twincat ADS protocol implementation
58 stars 21 forks source link

use multi read #3

Closed heleon19 closed 6 years ago

heleon19 commented 6 years ago

Hi How can I use the multi read function? Tried to pass the handle as array, but didn't work. Thank's for your advice. Regards Heleon

roccomuso commented 6 years ago

Please paste the whole code

heleon19 commented 6 years ago

Connection is ok, read of single variable is ok.

Example of multi read:

var myHandles =[
 {
    symname: '.light.gp[0]',  
    bytelength: ads.INT,  
},
 {
    symname: '.light.gp[1]',  
    bytelength: ads.INT,  
}
];

var client = ads.connect(options, function() {
    this.mulitRead(myHandles, function(err, handle) {
        if (err) console.log(err)
        console.log(handle.value)
    });
});
roccomuso commented 6 years ago

Try to put this listeners to catch errors:

client.on('notification', function(handle){
    console.log(handle)
})

client.on('error', function(error) {
    console.log(error)
})

I'm investigating the issue.

PLCHome commented 6 years ago

@roccomuso it should work properly with 1.4.3