"Acorn parse for compiler/plugins.js failed"

Posted on
  • I'm getting the message in the subject lines when I upload my program, but without any ill effect that I can detect. A Google search turns up no results.

    When the message displays it also says "Check editor window for errors", but there are no errors.

    Anyone have an idea what's going on?

  • Would you be able to post up the code that you're using so we can take a look?

    Usually it happens when you've got some JavaScript code that isn't valid somehow, but it can also happen when using newer ES6 features that the Acorn parser can't handle. About the only bad side effect is some things like the ability to compile code won't work for you.

  • Sure, here you go. The Web output is like a REST/JSON response that gives a sliding window of readings:

    {
    "current" : 41.4,
    "log" : [
    	{ "1514836500" : 47.9 },
    	{ "1514836800" : 41.4 },
    	{ "1514837100" : 39.5 },
    	{ "1514837400" : 39.3 },
    	{ "1514837700" : 39.1 },
    	{ "1514838000" : 39.1 },
    	{ "1514838300" : 38.9 },
        . . . .
    	{ "1515066900" : 41.4 },
    	{ "1515067200" : 41.4 },
    	{ "1515067500" : 41.4 }
    ]
    }
    

    I also send the readings to Graphite so I have a historical view (attached).

    // Wifi setup
    var WIFI_NAME = "myssid";
    var WIFI_OPTIONS = { password : "mypassword" };
    var wifi;
    
    // Where we are in the array.  Once full we'll shift and add to the end
    var arr_ptr = 0;
    
    // Max samples.  
    //    672 is 30 days of 15m samples
    //    4320 is 30 days of 5m samples
    var maxSamples = 4320;
    
    // How often to take a sample in seconds
    var sampleSec = 300;
    
    // Our sample arrays
    var ts_arr = Uint32Array(maxSamples);
    var temp_arr = Float32Array(maxSamples);
    
    // Array elements filled
    var arr_elements = 0;
    
    // Initial temperature setting
    var tempF = 32;
    
    // One wire object
    var ow = new OneWire(B0);
    
    // HTTP object
    var http = require("http");
    
    // Sensor object
    var sensor = require("DS18B20").connect(ow);
    
    // Fahrenheit?
    var fahr = true;
    
    // Graphite server
    graphite_host = "192.168.0.48";
    graphite_port = 2003;
    
    
    // Connect to WIfi
    function onInit() {
      wifi = require("EspruinoWiFi");
      wifi.connect(WIFI_NAME, WIFI_OPTIONS, function(err) {
        if (err) {
          console.log("Connection error: "+err);
          return;
        }
        console.log("Connected!");
        setTimeout(initProcess, 1000);
      });
    }
    
    // Get the temperature
    function updateTempF() {
      sensor.getTemp(function (sensor_temp) {
        tempF = ((sensor_temp * 9) / 5) + 32;
      });
    }
    
    
    // Initialization
    function initProcess() {
      // Get a page so we can get the current date from the header
      http.get("http://www.pur3.co.uk/hello.tx­t", function(res) {
        // Set our time bsaed on the header date
        now = res.headers.Date;
        epoch = Date.parse(now);
        setTime(epoch/1000);
        date = new Date();
        console.log("Init: ", date.toUTCString());
    
        // Set logging and the server to start after a few seconds
        updateTempF();
        setTimeout(startLogging, 3000);
        setTimeout(startServer, 5000);
      });
    }
    
    
    // Start our Web server
    function startServer() {
      console.log("Starting server");
      http.createServer(function (req, res) {
        updateTempF();
        res.writeHead(200, {'Content-Type': 'application/json'});
        if (arr_elements === 0) {
          res.end("{\n\"current\" : " + tempF.toFixed(1) + ",\n\"log\" : []\n}");
          return();
        }
        var i = 0; 
        res.on('drain', function() {
          for (var n = 0; n < 10; n++) {
            sample = "\n\t{ \"" + ts_arr[i] + "\" : " + temp_arr[i].toFixed(1)+ " }";
            res.write(sample);
            if (++i == arr_elements) {
              res.end("\n]\n}");
              break;
            }
            else {
              res.write(",");
            }
          }
        });
    
        page = "{\n\"current\" : " + tempF.toFixed(1) + ",\n\"log\" : [";
        res.write(page);
      }).listen(80);
    }
    
    
    // Start logging the temperature
    function startLogging() {
      console.log("Starting logging");
      setInterval(function() {
        sensor.getTemp(function (sensor_temp) {
          now = Date.now() / 1000;
          floor = parseInt(now);
          if (fahr)
            tempF = ((sensor_temp * 9) / 5) + 32;
          else
            tempf = sensor_temp;
          mod = floor % sampleSec;
          if (!mod) {
            if (arr_ptr == maxSamples) 
              arr_ptr = 0;
            ts_arr[arr_ptr] = parseInt(floor);
            temp_arr[arr_ptr++] = tempF;
            if (++arr_elements > maxSamples)
              arr_elements = maxSamples;
          }
          // Also send to Graphite
          socket = require("net").connect({"host" : graphite_host, "port" : graphite_port}, function() {
            msg = "espruino-attic-oaktreepeak-com.temperat­ure " + tempF + " " +  now + "\n";
            socket.write(msg);
            socket.end();
          });
        });
      }, 1000);
    }
    
    

    1 Attachment

    • graph.jpg
  • Looks great!

    It seems to be because you wrote return(). If you change it to return it should work. I'm actually surprised the linter didn't pick that up...

  • Geez, I move between C++, Python, Java, Scala . . . .

    All those have the parentheses. Habit!

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

"Acorn parse for compiler/plugins.js failed"

Posted by Avatar for user84292 @user84292

Actions