0

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.readInputRegister1 つのパラメーターを受け取りますが、ウォーターフォール チェーンに順番に応答を返す方法が見つかりません。

4

0 に答える 0