code: function sendCommand(sensor, cmd, callback)
  {
      // commands need to be terminated with a carriage return
      cmd += "\r";
      sensor.writeDataStr(cmd);
  
      // wait up to 1 second
      if (sensor.dataAvailable(1000))
      {
  	console.log("Returned: " + sensor.readDataStr(1024));
      }
      else
  	console.log("Timed out waiting for response");
  
      if (callback)
  	callback();
  }
docs: simple helper function to send a command and wait for a response