• Hi All,

    I am running the following GPS code:

    Serial4.setup(9600,{tx:C10,rx:C11});
    
    var SleepDuration = null;
    var SearchDuration = null;
    
    function Start_GPS(){
      
      console.log("Starting GPS...");
      //After 120 seconds disable the GPS regardless
      SearchDuration = setTimeout(function (e) { Stop_GPS(); }, 60000);
     
      //Set enable pin mode
      pinMode(A9,'output');
      
      //Set enable pin to high
      digitalWrite(A9,1);
      
      //load gps
        var gps = require("GPS").connect(Serial4, function(data) {
        console.log(data);
        //Check if we have a fix
          if(data.fix>0)
          {
            Stop_GPS();
            console.log("Send SMS:" + data.lat + "|" + data.lon);
          }
      });
    }
    
    function Stop_GPS(){
      clearTimeout(SearchDuration);
      digitalWrite(A9,0);
      console.log("Disabling GPS...");
    }
    
    function onInit(){
    SleepDuration = setTimeout(function (e) {onInit(); }, 120000);
    console.log("Starting up device & Setting timers...");
    Start_GPS();
    
    }
    
    onInit();
    

    I'm seeing an error popup every so often (not every time the code runs) as shown below:

    ERROR: Error processing Serial data handler - removing it.
    Execution Interrupted during event processing.
    Uncaught Error: Unknown Timeout
     at line 1 col 29
    {clearTimeout(SearchDuration);digitalWrite(A9,0);console.log...
                                 ^
    in function "Stop_GPS" called from line 1 col 44
    ...a);if(data.fix>0){Stop_GPS();console.log("Send SMS:"+data.la...
                                   ^
    in function "c" called from line 2 col 81
    ...,altitude:parseFloat(a[9])})}c=b.line.indexOf("\n")}}
                                   ^
    in function called from system
    Starting up device & Setting timers...
    Starting GPS...
    

    After leaving the code to execute I am eventually hitting:

    "lat":NaN,"lon":NaN,"fix":0,"ERROR: Out of Memory!
    satellit":0}
    WARNING: Unable to create string as not enough memory
    ERROR: Error processing Serial data handler - removing it.
    Execution Interrupted during event processing.
    at line 1 col 18
    {console.log(data);if(data.fix>0){Stop_in function called from system
    at line 2 col 81
    ...,altitude:parseFloat(a[9])})}c=b.line.indexOf("\n")}}
                                   ^
    in function called from system
    Disabling GPS...
    Starting up device & Setting timers...
    

    And even later on:

    Execution Interrupted during event processing.
    at line 1 col 144
    ...tr(3,3)){var a=a.split(","),d=a[2].indexOf("."),e=a[4].index...
                                   ^
    in function called from system
    Execution Interrupted during event processing.
    at line 1 col 144
    ...tr(3,3)){var a=a.split(","),d=a[2].indexOf("."),e=a[4].index...
                                   ^
    in function called from system
    WARNING: Out of memory while appending to array
    WARNING: Out of memory while appending to array
    WARNING: Out of memory while appending to array
    WARNING: Out of memory while appending to array
    WARNING: Out of memory while appending to array
    WARNING: Out of memory while appending to array
    WARNING: Out of memory while appending to array
     
    

    Just wondering if anyone can see whats going wrong here? I assume it might be to do with the setTimeouts and then clearing them?

About