• Hi - thanks for letting me know, and for including the traces... That's an odd one - there doesn't appear to be any obvious cause of the leak. The GPS code is actually pretty simple, see: https://github.com/espruino/EspruinoDocs­/blob/master/devices/GPS.js

    All I can think is that the GPS doesn't send any newline characters while it is searching for a lock, but that doesn't explain the permanent leak.

    Unfortunately as it is, it's hard to see what the problem is, or what the data being read is. Can you try:

    var exports = {};
    
    function handleGPSLine(line, callback) {
      var tag = line.substr(3,3);
      if (tag=="GGA") {
        var d = line.split(",");
        var dlat = d[2].indexOf(".");
        var dlon = d[4].indexOf(".");
        callback({
          time : d[1].substr(0,2)+":"+d[1].substr(2,2)+":­"+d[1].substr(4,2),
          lat : (parseInt(d[2].substr(0,dlat-2),10)+pars­eFloat(d[2].substr(dlat-2))/60)*(d[3]=="­S"?-1:1),
          lon : (parseInt(d[4].substr(0,dlon-2),10)+pars­eFloat(d[4].substr(dlon-2))/60)*(d[5]=="­W"?-1:1),
          fix : parseInt(d[6],10),
          satellites : parseInt(d[7],10),
          altitude : parseFloat(d[9])
        });
      }
    }
    
    
    exports.connect = function(serial, callback) {
      var gps = { line : "" };
      serial.onData(function(d) {
        if (d.data=="\n") {
          var line = gps.line;
          gps.line="";
          handleGPSLine(line, callback);      
        } else gps.line+=d.data;
      });
      return gps;
    }
    
    Serial4.setup(9600,{tx:C10,rx:C11});
    var gps = exports.connect(Serial4, function (data) {
            if ((data.time.substr(-2))=="00") {
                console.log("time = "+data.time);
                console.log("lat = "+data.lat);
                console.log("lon = "+data.lon);
            }
    });
    

    Then you should be able to check on what gps.line is. Perhaps you could also change the beginning of serial.onData(function(d) { to:

    serial.onData(function(d) {
      USB.write(d);
      ...
    

    That'll spam loads of stuff over the console, but it will show you what data Espruino is getting from the GPS while it's waiting for a lock.

About

Avatar for Gordon @Gordon started