mathiask88 / node-snap7

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

Issue reading and writing mulitple bits #31

Closed acrippa closed 6 years ago

acrippa commented 6 years ago

Hello, I'm having problems writing and reading multiple bits with one call of "ReadArea".

s7client.ReadArea(s7client.S7AreaDB, 1, 0, 2, s7client.S7WLBit, function(err,res){
    if(err)
        return console.log(' >> DBRead failed. Code #' + err + ' - ' + s7client.ErrorText(err));
    console.log(" >> DBRead succesful",res)
});

I get the error ">> DBRead failed. Code #10485760 - CPU : Invalid Transport size". Tested with a CPU S7-314C-2 PN/DP and a CPU S7-1511-1 PN.

I get the same error trying to write multiple bits using WriteArea. Everything goes fine if I read(write) those bits one by one with multiple calls of "ReadArea"("WriteArea").

I have no problems reading and writing multiple bytes or words.

What could be the cause of that error?

mathiask88 commented 6 years ago

Hey, as far as I remember the S7 Protocol does not allow reading more than one bit at a time. If you want to do this you have to read the whole byte and extract your bits.

mathiask88 commented 6 years ago

Another option would be to use the MultiVars functions. But I think you got a solution for your issue, so I'll close this. If you still got problems, feel free to reopen.