GPS Recorder: invalid Date of Track

Posted on
  • Hi! There was a problem: I can not download routes from my watch to my computer. I want to get .GPX or KML, but when loading data, it shows an error (Track, Invalid Date).

    The routes are displayed normally on the watch, but I cannot download them.

    I can only get approximate data for routes through IDE, of the following form: .gpsrcp, .gpsrcq, ...etc, but it is not convenient to work with them.

    Any ideas on how to fix this and download the routes in .GPX format?

    Thanks!


    1 Attachment

    • banglejs.com_apps_.png
  • Are all your routes ones with a route number greater than 9?

    If you open the Chrome developer console, do you see any errors shown when you're running the GPS recorder loader?

    When you're connected with the Web IDE, please could you paste this into the left-hand side:

    for (var n=0;n<36;n++) {
          var f = require("Storage").open(".gpsrc"+n.toStr­ing(36),"r");
          var l = f.readLine();
          if (l!==undefined)
            Bluetooth.println(n+","+l.trim());
        }
    

    and paste up what gets printed? It might be one of the files has got some unexpected data in and that's thrown off the file loader.

  • Are all your routes ones with a route number greater than 9?

    Exactly :)

    If you open the Chrome developer console, do you see any errors shown when you're running the GPS recorder loader?

    Nope. Everything is fine, there are no errors in the console (banglejs.com/apps).

    And data from Web IDE is:

  • Please can you try just opening the launcher on Bangle.js, then connecting and seeing if you can download via GPS Recorder?

    I just generated a track>10 here and the download works, and it seems that the code you pasted above works perfectly (which is the exact code the GPS Recorder downloader uses). So all I can think is maybe the clock face that you're using is printing some data to the console or delaying a long time, and that's interfering with receiving the track list.

  • Please can you try just opening the launcher on Bangle.js, then connecting and seeing if you can download via GPS Recorder?

    I did this. Also i tried to uninstall different applications and the clock faces, but unfortunately it did not help. Problem still exists. Perhaps the fastest way would be to do a HARD RESET.

    Is there a way to convert files with GPS data downloaded from the watch directly to the GPX? I mean not via https://banglejs.com/apps/ but via a third party converter?

  • That's really strange - and you're sure there are no errors?

    Could you open the Chrome dev console when connected, type Puck.debug=3 in it and then open the GPS recorder downloader and paste what gets printed here? I guess it's possible that it takes a while to output the list of files, and it times out?

    Yes - right now there isn't a converter that 'just works', but if you gave me the files I could convert them.

    The actual code for doing the conversion is at https://github.com/espruino/BangleApps/b­lob/master/apps/gpsrec/interface.html

    You just put every line of the file through trackLineToObject(line,false) and then put it in saveGPX and it'll do everything for you. In fact I could even add an 'import' dialog on that page to do it for you pretty easily.

  • Could you open the Chrome dev console when connected, type Puck.debug=3 in it and then open the GPS recorder downloader and paste what gets printed here?

    Sure. Here's the complete response from the console:

    Puck.debug=3
    3
    puck.js:371 <BLE> Sending "\u0010(function() {\n "
    puck.js:371 <BLE> Sent
    puck.js:371 <BLE> Sending "   for (var n=0;"
    puck.js:371 <BLE> Sent
    puck.js:371 <BLE> Sending "n<36;n++) {\n    "
    puck.js:371 <BLE> Sent
    puck.js:371 <BLE> Sending "  var f = requir"
    puck.js:371 <BLE> Sent
    puck.js:371 <BLE> Sending "e(\"Storage\").ope"
    puck.js:371 <BLE> Sent
    puck.js:371 <BLE> Sending "n(\".gpsrc\"+n.toS"
    puck.js:371 <BLE> Sent
    puck.js:371 <BLE> Sending "tring(36),\"r\");\n"
    puck.js:371 <BLE> Sent
    puck.js:371 <BLE> Sending "      var l = f."
    puck.js:371 <BLE> Sent
    puck.js:371 <BLE> Sending "readLine();\n    "
    puck.js:371 <BLE> Sent
    puck.js:371 <BLE> Sending "  if (l!==undefi"
    puck.js:371 <BLE> Sent
    puck.js:371 <BLE> Sending "ned)\n        Blu"
    puck.js:371 <BLE> Sent
    puck.js:371 <BLE> Sending "etooth.println(n"
    puck.js:371 <BLE> Sent
    puck.js:371 <BLE> Sending "+\",\"+l.trim());\n"
    puck.js:371 <BLE> Sent
    puck.js:371 <BLE> Sending "    }\n  })()\n"
    puck.js:371 <BLE> Sent
    puck.js:371 <BLE> Received "21,1613468828000,50."
    puck.js:371 <BLE> Received "261702,19.054179,306"
    puck.js:371 <BLE> Received ".4\r\n"
    puck.js:371 <BLE> Received "22,1613748890000,50."
    puck.js:371 <BLE> Received "259493,19.052839,254"
    puck.js:371 <BLE> Received ".2\r\n"
    puck.js:371 <BLE> Received "23,1613914821000,50."
    puck.js:371 <BLE> Received "262469,19.054682,256"
    puck.js:371 <BLE> Received "\r\n"
    puck.js:371 <BLE> Received "24,1614008040000,50."
    puck.js:371 <BLE> Received "263432,19.053135,270"
    puck.js:371 <BLE> Received ".5\r\n"
    puck.js:371 <BLE> Received "25,1614182126000,50."
    puck.js:371 <BLE> Received "259883,19.038182,248"
    puck.js:371 <BLE> Received ".8\r\n"
    puck.js:371 <BLE> Received "26,1614272826000,50."
    puck.js:371 <BLE> Received "261817,19.059988,254"
    puck.js:371 <BLE> Received ".6\r\n"
    puck.js:371 <BLE> Received "27,1614332036000,50."
    puck.js:371 <BLE> Received "260909,19.056641,265"
    puck.js:371 <BLE> Received "\r\n"
    puck.js:371 <BLE> Received "28,1614530565000,50."
    puck.js:371 <BLE> Received "259727,19.060739,269"
    puck.js:371 <BLE> Received ".6\r\n"
    puck.js:371 <BLE> Received "29,1614703251000,50."
    puck.js:371 <BLE> Received "259834,19.067476,276"
    puck.js:371 <BLE> Received ".3\r\n"
    puck.js:371 <BLE> Received "30,1614790117000,50."
    puck.js:371 <BLE> Received "259776,19.056448,253"
    puck.js:371 <BLE> Received ".9\r\n"
    
  • You just put every line of the file through trackLineToObject(line,false) and then put it in saveGPX and it'll do everything for you. In fact I could even add an 'import' dialog on that page to do it for you pretty easily.

    Understood thanks. Well, first I'll try to do everything myself :)

  • Thanks! Well that's a surprise - so it all seems to be working fine on the Bangle - just for some reason the interface on the PC isn't understanding the received data.

    I even copied the file contents I see in your dump and put them into files on a Bangle and ran the GPS recorder interface and it listed all the files for me!

    But this did give me a thought. In the dev console, it should be possible to run a command like:

    downloadTrack(21, track => saveGPX(track, `Bangle.js Track`));
    

    To kick off the download manually - although it needs to be debugging the iframe at that point, so I wonder how you do that.

  • I made a converter that solves my problem at this moment.
    Demo: https://zloid.github.io/convert-gps-reco­rder-raw-data-to-gpx/
    Source: https://github.com/zloid/convert-gps-rec­order-raw-data-to-gpx

    Also, this tool will be useful for those who will have a similar problem and want to convert the routes files to GPX in an easy way.

    This converter uses some of the code from https://github.com/espruino/BangleApps/b­lob/master/apps/gpsrec/interface.html

    And here's what I noticed when I was making the tool: all the raw route files downloaded from the watch have one blank line at the end. If such a file gets into

    trackLineToObject ("", false)
    

    , then the output will be

    {date: Invalid Date, lat: NaN, lon: NaN, alt: NaN}
    

    Perhaps this is causing the error? When files with routes may contain empty lines.

  • Thanks! That's great! I guess it could be to do with blank lines or something like that?

    If you're willing to have a go at debugging it you could try breakpointing in getTrackList: https://github.com/espruino/BangleApps/b­lob/master/apps/gpsrec/interface.html#L1­05

    And see what actually gets returned to it?

  • Thanks :)

    So, I played around with Debugger and here's the result:

    Most likely my assumptions are correct: somehow the GPS Recorder writes empty lines to routes, and interface.html cannot process the empty line correctly, right? Therefore, an error occurs with the Invalid Date and NaN.

    Could you please add empty line handling to interface.html? Empty lines from routes must either be ignored or incorrect data must be deleted during the execution of the script (the track's data where there is NaN).

  • Thanks! Just to be sure, what's in trackLines? Is there actual data in there, or is it just blank lines?

    I just added blank line handling to the development version at https://espruino.github.io/BangleApps/ so I'd be interested to see if that helps

  • Well, at this moment i have:

    from //espruino.github.io/BangleApps:


    1 Attachment

    • trackLines_dev.png
  • And this is an example of a recorded route. There is an empty line at the end (in each route), maybe this is the reason for the error?


    1 Attachment

  • Ok, it sounds like that's probably not your issue then. tracklist is completely blank, which means that the Puck.write command hasn't received any data (but it appears to actually be there when you did Puck.debug = 3).

    So about the only thing I can think here is that it's actually timed out waiting for a response. If you paste this into the IDE:

    var t = getTime(); for (var n=0;n<36;n++) {
          var f = require("Storage").open(".gpsrc"+n.toStr­ing(36),"r");
          var l = f.readLine();
          if (l!==undefined)
            Bluetooth.println(n+","+l.trim());
        } print(getTime()-t)
    

    What number does it give right at the end?

  • Ok, can you try now with the development version?

    Now, it outputs something (a blank line) even for files that don't exist - it should hopefully stop the command timing out

  • Great! New routes are displayed normally. Thanks :)

    Question: Why is the number of routes limited by 36? Does it have a special reason? How about the number 365, that is, one route a day, for a year :)

    And here is the data from the IDE:


    1 Attachment

    • what_time_bangle_js_2.png
  • Great! Glad that sorted it!

    Why is the number of routes limited by 36?

    It's left over from when filenames were limited in length to 8 characters - so I used 0..9, A..Z to allow one character in the filename. It's something I've been meaning to improve on.

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

GPS Recorder: invalid Date of Track

Posted by Avatar for Serj @Serj

Actions