我在尝试使用 modbus-tcp 时遇到问题async.waterfall
基本上我必须先完成一个 modbus 读取,然后再继续另一个。
async.waterfall([
function startInfo(next) {
console.log("Dummy Starting A")
next(null, 'A')
},
function startInfo(parm, next) {
console.log("Dummy Starting B")
next(null, 'B')
},
function (parm, next) {
function readSerial() {
client.readInputRegister(35, 2, ProcessSerial)
}
readSerial(); //executes the read(?), but the ProcessSerial is still out of "serial execution"
next(null)
},
function dumpSerial(next) {
console.log('serial:' + serial)
next(null)
},
function readAppKey(next) {
client.readInputRegister(2059, 4, ProcessAppKey)
},
function dumpAppKey() {
console.log('appkey:' + app)
}
],
function completed(err, result) {
console.log("Complete");
}
);
//
function ProcessSerial(resp, next) {
serial = "" + (resp.register[0] * 65536 + resp.register[1])
//next(null); //
}
function ProcessAppKey(resp) {
var sub = ((resp.register[3] & 0xFF00) >> 8) + "." + (resp.register[3] & 0x00FF);
app = "" + String.fromCharCode(resp.register[0]) + resp.register[1] + " V" + resp.register[2] + " (" + sub + ")";
}
client.readInputRegister
接受一个参数,我无法找到一种方法来按顺序将响应返回到瀑布链。