Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/454.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/clojure/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何从node.js中的async.瀑布中的链中调用外部函数_Javascript_Node.js_Modbus_Node Async - Fatal编程技术网

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
,因此第三个瀑布任务什么都不做(除了定义一个从未使用过的本地函数)。对吗?我在故障排除中漏掉了一行,很好。