You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

vpl.cc 6.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. /*
  2. Reader for Honda/Acura (Alpine) Navigation System VP Log (VPL) files
  3. Copyright (C) 2009 Chris Tracy, gpsbabel@adiemus.org
  4. Copyright (C) 2005 Robert Lipe, robertlipe+source@gpsbabel.org
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program; if not, write to the Free Software
  15. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111 USA
  16. */
  17. /*
  18. With logging enabled (Diagnostic Menu | Functional Setup | Log Data), VPL
  19. files are written to the PC Card. The files themselves are written out as
  20. ASCII files, mostly containing lines of hexadecimal characters. The format
  21. seems similar to NMEA, with various sentences carrying different types of
  22. information. For our purposes, the only sentence that matters is the '75'
  23. sentence. For example:
  24. 75700241FA59FB242CD500CF041984991E0B0A0C09060613064509060613064424824D68FF00000800051C000271
  25. 00--1111111122222222333344445555--667788999999999999AAAAAAAAAAAA--------------------------XX
  26. 0 - Sentence type
  27. 1 - Latitude in hex (signed, divide by 0xE1000 for decimal degrees)
  28. 0241FA59 -> 37878361 / 0xE1000 = 41.100652
  29. 2 - Longitude in hex (signed, divide by 0xE1000 for decimal degrees)
  30. FB242CD5 -> -81515307 / 0xE1000 = -88.449769
  31. 3 - Altitude (signed, meters)
  32. 00CF -> 207
  33. 4 - Speed (divide by 0x10 for MPH)
  34. 0419 -> 1049 / 0x10 = 65.5625
  35. 5 - Heading (multiply by 360/65535 to constrain to 0 - 360 degrees)
  36. 8499 -> 33945 * (360/65535) = 186.47
  37. 6 - Number of sats
  38. 0B -> 11
  39. 7 - HDOP (divide by 8)
  40. 0A -> 10 / 8 = 1.25
  41. 8 - VDOP (divide by 8)
  42. 0C -> 12 / 8 = 1.5
  43. 9 - Date and Time (YYMMDDHHMMSS)
  44. 090606130645 = June 6, 2009 13:06:45
  45. A - Previous line date and time (?)
  46. 090606130644 = June 6, 2009 13:06:44
  47. X - Checksum (xor, ala NMEA)
  48. ***********************************
  49. * Unused, but (at least partially) decoded sentences
  50. ******
  51. 0D - Yaw Gyro (This field is not currently decoded herein)
  52. This field is written 25 times per second. It contains the raw values
  53. from the yaw gyro. Positive values for right turns, negative values
  54. for left turns.
  55. 0D00FEFA09
  56. 00??1111CC
  57. 0 - Sentence Type
  58. ? - An unknown field with observed values between 0 and 3.
  59. 1 - Yaw Gyro value
  60. C - Checksum
  61. ******
  62. 31 - Distance Traveled
  63. This field is written once a second. It contains the number of
  64. meters traveled since the navigation system was last turned on.
  65. 310000117050
  66. 0011111111CC
  67. 0 - Sentence Type
  68. 1 - Distance Traveled in Meters
  69. C - Checksum
  70. ******
  71. 35 - Raw Position
  72. This field is written 5 times per second. It contains Latitude
  73. and Longitude, as well as two currently unknown angular values.
  74. 35CFBB5CBC1744CB1BD9023308C2
  75. 00111111112222222233334444CC
  76. 0 - Sentence Type
  77. 1 - Longitude (divide by 0x8CA000 for decimal degrees)
  78. 2 - Latitude (divide by 0x8CA000 for decimal degrees)
  79. 3 - Unknown angular value (multiply by 360/65535)
  80. 4 - Unknown angular value (multiply by 360/65535)
  81. C - Checksum
  82. */
  83. /*
  84. TODO:
  85. - Implement checksum verification
  86. */
  87. #include "defs.h"
  88. #include <stdio.h> /* for sscanf */
  89. #define MYNAME "vpl"
  90. void vpl_parse_75_sentence(const char*);
  91. static
  92. arglist_t vpl_args[] = {
  93. ARG_TERMINATOR
  94. };
  95. static gbfile* vpl_file_in;
  96. static route_head* track_head;
  97. /*******************************************************************************
  98. * %%% global callbacks called by gpsbabel main process %%% *
  99. *******************************************************************************/
  100. static void
  101. vpl_rd_init(const QString& fname)
  102. {
  103. vpl_file_in = gbfopen(fname, "r", MYNAME);
  104. }
  105. static void
  106. vpl_rd_deinit(void)
  107. {
  108. gbfclose(vpl_file_in);
  109. }
  110. static void
  111. vpl_read(void)
  112. {
  113. char* ibuf;
  114. // Set up a track
  115. if (track_head == NULL) {
  116. track_head = route_head_alloc();
  117. track_add_head(track_head);
  118. }
  119. while ((ibuf = gbfgetstr(vpl_file_in))) {
  120. if (strncmp(ibuf, "75", 2) == 0) {
  121. vpl_parse_75_sentence(ibuf);
  122. }
  123. }
  124. }
  125. static void
  126. vpl_wr_init(const QString& fname)
  127. {
  128. fatal("Writing file of type %s is not support\n", MYNAME);
  129. }
  130. /*******************************************************************************
  131. * Local Functions
  132. *******************************************************************************/
  133. void
  134. vpl_parse_75_sentence(const char* ibuf)
  135. {
  136. uint32_t ymd, hms;
  137. int32_t lat_raw, lon_raw;
  138. int16_t alt, speed_raw;
  139. uint16_t hdg_raw;
  140. uint8_t sats, hdop_raw, vdop_raw;
  141. Waypoint* waypt;
  142. struct tm tm;
  143. // The files have DOS line endings (CR/LF) but we don't care, because we
  144. // don't read to the end.
  145. sscanf(ibuf, "75%*2c%8X%8X%4hX%4hX%4hX%*2c%2hhX%2hhX%2hhX%6u%6u",
  146. &lat_raw, &lon_raw, &alt, &speed_raw, &hdg_raw, &sats, &hdop_raw, &vdop_raw,
  147. &ymd, &hms);
  148. tm.tm_sec = hms % 100;
  149. hms /= 100;
  150. tm.tm_min = hms % 100;
  151. hms /= 100;
  152. tm.tm_hour = hms % 100;
  153. tm.tm_mday = ymd % 100;
  154. ymd /= 100;
  155. tm.tm_mon = ymd % 100;
  156. ymd /= 100;
  157. tm.tm_year = ymd % 100 + 100;
  158. waypt = new Waypoint;
  159. // Lat/Lon are both stored *0xE1000 which we have to divide out
  160. // for decimal degrees
  161. waypt->latitude = lat_raw / (double) 0xE1000;
  162. waypt->longitude = lon_raw / (double) 0xE1000;
  163. waypt->altitude = alt;
  164. waypt->sat = sats;
  165. // Speed comes in (MPH x 0x10) which we have to convert to m/s
  166. WAYPT_SET(waypt, speed, (speed_raw / (double) 0x10) * 0.44704);
  167. waypt->course = hdg_raw * (double)(360/65535);
  168. waypt->hdop = hdop_raw / (double) 8;
  169. waypt->vdop = vdop_raw / (double) 8;
  170. waypt->SetCreationTime(mkgmtime(&tm));
  171. track_add_wpt(track_head, waypt);
  172. }
  173. /**************************************************************************/
  174. ff_vecs_t vpl_vecs = {
  175. ff_type_file,
  176. {
  177. ff_cap_none /* waypoints */,
  178. ff_cap_read /* tracks */,
  179. ff_cap_none /* routes */
  180. },
  181. vpl_rd_init,
  182. vpl_wr_init,
  183. vpl_rd_deinit,
  184. NULL,
  185. vpl_read,
  186. NULL,
  187. NULL,
  188. vpl_args,
  189. CET_CHARSET_ASCII, /* ascii is the expected character set */
  190. 1 /* fixed, can't be changed through command line parameter */
  191. };
  192. /**************************************************************************/