6

I need to read data from a GPSMap 62 device using the device control Javascript library. Problem is, unlike older devices, this device stores its waypoints in separate .GPX files every day. The javascript library expects all tracks and waypoints to be in the current.gpx file, but the 62 stores them in e.g. Waypoints_06-MAY-14.gpx and so on each day.

Short of requiring users to manually upload the appropriate file, has anyone gotten the DeviceControl library to actually support the newer devices with separate GPX files?

As an added bonus, the Garmin Device Control library is deprecated, so no updates are forthcoming.

Some code

startReadFromGps: function(deviceNumber) {
     this.plugin.StartReadFromGps( deviceNumber ); //invokes the external plugin
},
Captain Kenpachi
  • 6,960
  • 7
  • 47
  • 68
  • cant you just rename the waypoints...gpx file to current.gpx? or just add the content to it ? – Dwza May 14 '14 at 15:05
  • Yes, but the point is to let users have a nice seamless experience. I can't ask the user, who may only be semi-computer literate to start messing around with his GPS's files. ANd therein lies the problem. – Captain Kenpachi May 14 '14 at 15:09
  • @JuannStrauss cant the process of renaming be automated? – coder hacker May 14 '14 at 15:17
  • This seems like it would be easier in some other language? Is JavaScript a requirement? – Evan Knowles May 14 '14 at 15:21
  • Sadly not. The Garmin DeviceControl library is written in Javascript and works in conjunction with the Garmin Browser Plugin. If I were developing a desktop or windows store app, this wouldn't be such and issue, but the fact that it's a web application makes it absurdly difficult. – Captain Kenpachi May 14 '14 at 15:26
  • this is what i meant. the script could open the file and just rename it or may add the content to an other file... my ajax or some... does the garmin connects to the internet or should all be on the gamin self ? – Dwza May 14 '14 at 16:30
  • Could you add some code to illustrate what you were doing with the older devices? – Zlatin Zlatev May 21 '14 at 06:33
  • I guess a good deal would be to merge those files, then read data from them. – user3241019 May 21 '14 at 07:31
  • Because this is a web/browser based application, the local storage access is handled by a proprietary browser plugin developed by Garmin and is NOT open source. The only access you have to the file is via the ReadFromDevice() function which only takes filetype as an argument, not filepath. – Captain Kenpachi May 21 '14 at 07:46

1 Answers1

1

I've checked out plugin in version 2.3-RC1 (I do not know, which version do you use).

Indeed there is startReadFromGps method:

/** Initiates the read from the gps device conneted. Use finishReadFromGps and getGpsProgressXml to 
 * determine when the plugin is done with this operation. Also, use getGpsXml to extract the
 * actual data from the device. <br/>
 * <br/>
 * Minimum plugin version 2.0.0.4
 * 
 * @param deviceNumber {Number} assigned by the plugin, see getDevicesXml for 
 * assignment of that number.
 * @see #finishReadFromGps
 * @see #cancelReadFromGps
 * @see #getDevicesXml
 */
startReadFromGps: function(deviceNumber) {
     this.plugin.StartReadFromGps( deviceNumber );
},

So it uses getGpsXml. I assume that it uses specified filename that is read and method returns file's content. My first thought is to change the filename - it is possible with:

/** This the filename that wil contain the gps xml once the transfer is complete. Use with 
 * setWriteGpsXml to set what the file contents will be. Also, use startWriteToGps to 
 * actually make the write happen.
 * 
 * @private
 * @param filename {String} the actual filename that will end up on the device. Should only be the
 * name and not the extension. The plugin will append the extension portion to the file name--typically .gpx.
 * @see #setWriteGpsXml, #startWriteToGps, #startWriteFitnessData
 */
_setWriteFilename: function(filename) {
    this.plugin.FileName = filename;
},

But _setWriteFilename is private method. However called by

startWriteToGps: function(gpsXml, filename, deviceNumber)

and

startWriteFitnessData: function(tcdXml, deviceNumber, filename, dataTypeName)

Since now I will check if calling those methods with your specified filename will override filename value permanently and further calling of startReadFromGps will use new filename.

I cannot test it, I didn't use this library but you can give a shot.

hsz
  • 148,279
  • 62
  • 259
  • 315