title: How do I call an external function from within a chain in async.waterfall in node.js
body: <p>I have a problem when trying to use modbus-tcp in <code>async.waterfall</code>
  Basically I have to complete one modbus read before continuing the other.</p>
  
  <pre><code>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] &amp; 0xFF00) &gt;&gt; 8) + "." + (resp.register[3] &amp; 0x00FF);
          app = "" + String.fromCharCode(resp.register[0]) + resp.register[1] + " V" + resp.register[2] + " (" + sub + ")";
      }
  </code></pre>
  
  <p>The <code>client.readInputRegister</code> takes one parameter and I can't find a way to get response back to the waterfall chain in sequence.</p>