Javascript 如何从node.js中的async.瀑布中的链中调用外部函数
在Javascript 如何从node.js中的async.瀑布中的链中调用外部函数,javascript,node.js,modbus,node-async,Javascript,Node.js,Modbus,Node Async,在async.falter 基本上,我必须先完成一个modbus读取,然后再继续另一个 async.waterfall([ function startInfo(next) { console.log("Dummy Starting A") next(null, 'A') }, function startInfo(parm, next) { console.log("Dumm
async.falter
基本上,我必须先完成一个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
接受一个参数,我找不到一种方法来按顺序返回瀑布链的响应。在代码中从不调用readSerial
,因此第三个瀑布任务什么都不做(除了定义一个从未使用过的本地函数)。对吗?我在故障排除中漏掉了一行,很好。