9 Replies Latest reply on Aug 24, 2016 2:59 PM by w4ilun

    Intel Edison won't run XDK Project on Startup

    Shiven

      My Intel Edison Project, a modification of the example:

       

      /*jslint node:true, vars:true, bitwise:true, unparam:true */
      /*jshint unused:true */
      /*global */
      /*
      A simple node.js application intended to read data from Analog pins on the Intel based development boards
      such as the Intel(R) Galileo and Edison with Arduino breakout board, and display it in a browser running on the client.
      
      
      This demonstrates use of http.createServer, and fs.
      
      
      MRAA - Low Level Skeleton Library for Communication on GNU/Linux platforms
      Library in C/C++ to interface with Galileo & other Intel platforms, in a structured and sane API with port nanmes/numbering that match boards & with bindings to javascript & python.
      
      Steps for installing MRAA & UPM Library on Intel IoT Platform with IoTDevKit Linux* image
      Using a ssh client:
      1. echo "src maa-upm http://iotdk.intel.com/repos/1.1/intelgalactic" > /etc/opkg/intel-iotdk.conf
      2. opkg update
      3. opkg upgrade
      
      
      Article: https://software.intel.com/en-us/xdk-sample-creating-a-web-server
      */
      
      
      // Set this to the ip address of your board (not 127.0.0.1)
      var ipAddress = '192.168.1.80';
      
      
      var mraa = require('mraa'); //require mraa
      console.log('MRAA Version: ' + mraa.getVersion()); //write the mraa version to the console
      
      
      // Start by loading in some data
      var fs = require('fs');
      
      
      var lightSensorPage = fs.readFileSync('/node_app_slot/lightsensor.html');
      
      
      // Insert the ip address in the code in the page
      
      
      lightSensorPage = String(lightSensorPage).replace(/<<ipAddress>>/, ipAddress);
      
      
      var myDigitalPin6 = new mraa.Gpio(6); //setup digital read on Digital pin #6 (D6)
      myDigitalPin6.dir(mraa.DIR_IN); //set the gpio direction to input
      /**
      * Given a value, convert it to Lux
      *
      * This uses the table given in the documentation for the
      * Grove Starter Kit Plus. We have not sought to verify these
      * values with our device. That would be worth doing if you
      * intend to rely on these values. In that case, it could also
      * be worthwhile to improve the interpolation formula
      * @param {Number} - the raw reading from the device
      */
      
      
      var http = require('http');
      http.createServer(function (req, res) {
          var value;
          // This is a very quick and dirty way of detecting a request for the page
          // versus a request for light values
          if (req.url.indexOf('lightsensor') != -1) {
              res.writeHead(200, {'Content-Type': 'text/html'});
              res.end(lightSensorPage);
          }
          else {
              value = myDigitalPin6.read();
              res.writeHead(200, {'Content-Type': 'text/json'});
              res.end(JSON.stringify(value));
          }
      }).listen(1337, ipAddress);
      
      

       

       

      Once uploaded to the board in the Intel XDK, can be run using the run button. If i unplug the board and plug it back in, the project won't run on startup, but after it starts up, i can manually start it by using the run button in the XDK IDE. Any help?

       

      I am using the mini breakout and the Yocto 3.0 image.