title: infinite loop recursively with node.js
body: <p>I want to loop through some functions recursively so that after last function again it goes to first one and it goes forever. Can anyone please help me out on that? I also want to know if there is proper tutorial or something that will help me out to solve these problem in node js looping and flow controlling. I tried online tutorial though But not able to understand properly.</p>
  
  <pre><code>var util = require('util');
  var async = require('async');
  var SensorTag = require('./index');
  var USE_READ = true;
  
  SensorTag.discover(function(sensorTag) {
    console.log('discovered: ' + sensorTag);
  
    sensorTag.on('disconnect', function() {
      console.log('disconnected!');
      process.exit(0);
    });
  
    async.series([
    /*func 1*/
        function(callback) {
          console.log('connectAndSetUp');
          sensorTag.connectAndSetUp(callback);
        },
    /*func 2*/
        function(callback) {
          console.log('readDeviceName');
          sensorTag.readDeviceName(function(error, deviceName) {
            console.log('\tdevice name = ' + deviceName);
            callback();
          });
        },
     /*func 3*/
        function(callback) {
          console.log('readSystemId');
          sensorTag.readSystemId(function(error, systemId) {
            console.log('\tsystem id = ' + systemId);
            callback();
          });
        }
    })
  
  })
  </code></pre>
  
  <p>When I executed it goes func 1 -> func 2 -> func 3 and then hangs. I need to recursively loop these again and again.</p>
  
  <p>Edit code :I TRIED TO LOOP SOME FUNCTIONS, not all </p>
  
  <pre><code>var util = require('util');
  var async = require('async');
  var SensorTag = require('./index');
  var USE_READ = true;
  
  SensorTag.discover(function(sensorTag) {
    console.log('discovered: ' + sensorTag);
  
    sensorTag.on('disconnect', function() {
      console.log('disconnected!');
      process.exit(0);
    });
  
  //function loop(){
    async.series([
    /*func 1*/
        function(callback) {
          console.log('connectAndSetUp');
          sensorTag.connectAndSetUp(callback);
        },
        function loop(callback){
          /*func 2*/
        function(callback) {
          console.log('readDeviceName');
          sensorTag.readDeviceName(function(error, deviceName) {
            console.log('\tdevice name = ' + deviceName);
            callback();
          });
        },
     /*func 3*/
        function(callback) {
          console.log('readSystemId');
          sensorTag.readSystemId(function(error, systemId) {
            console.log('\tsystem id = ' + systemId);
            callback();
          });
        },
        function(callback){
          loop()
          callback()
        }
  
        }
  /*
        function(callback) {
          console.log('readDeviceName');
          sensorTag.readDeviceName(function(error, deviceName) {
            console.log('\tdevice name = ' + deviceName);
            callback();
          });
        },
  
        function(callback) {
          console.log('readSystemId');
          sensorTag.readSystemId(function(error, systemId) {
            console.log('\tsystem id = ' + systemId);
            callback();
          });
        },*/
        /*func 4*/
        loop();
  
    ]);
  }
  
  
  
  })
  </code></pre>