Administrative

Projects

Active

Future

Finished

Reference

Abandoned

Project: GPSLogger

Data storage format for the GPS logger

Data storage format

We save the data in ASCII representation, even if we could pack this into some byte less by storing it directly in binary - at least at the moment this seems easier to me. If during implementation this opinion changes, so might the storage model defined here...

offset                           !0912292357N5336671E01002239XXXXXXXXXXXXXXXX.
00  Version indicator -----------^| | | | | || | |  ||  | |  |               |
01  Year, two-digit --------------+ | | | | || | |  ||  | |  |               |
03  Month --------------------------+ | | | || | |  ||  | |  |               |
05  Day ------------------------------+ | | || | |  ||  | |  |               |
07  Hours, 24h-format ------------------+ | || | |  ||  | |  |               |
09  Minutes ------------------------------+ || | |  ||  | |  |               |
11  North/South indicator ------------------+| | |  ||  | |  |               |
12  2 digit degrees -------------------------+ | |  ||  | |  |               |
14  Minutes -----------------------------------+ |  ||  | |  |               |
16  3-digit fractions of minutes ----------------+  ||  | |  |               |
19  East/West indicator ----------------------------+|  | |  |               |
20  3 digit degrees ---------------------------------+  | |  |               |
23  Minutes --------------------------------------------+ |  |               |
25  3-digit fractions of minutes -------------------------+  |               |
28  16 byte reserved for future use -------------------------+               |
44  End of dataset indicator ------------------------------------------------+

Size is 45 byte per dataset.

struct dataset {
  /* version indicator */
  char version;
  /* timestamp for measurement */
  char ts_year[2];
  char ts_month[2];
  char ts_day[2];
  char ts_hours[2];
  char ts_minutes[2];
  /* measured position */
  char gps_lat_ns;
  char gps_lat_deg[2];
  char gps_lat_min[5];
  char gps_lon_ew;
  char gps_lon_deg[3];
  char gps_lon_min[5];
  /* reserved for future use */
  char reserved[16];
  char enddot;
}

Version number of the dataset format is ASCII value of version indicating character minus 32, e.g. this version is marked !, ASCII (decimal) 33, so this is format version 1. Printable characters end at 26, so we can come up with 94 versions of the format (while version 94 might of course define another two-byte version indicator). I want this to be future-proof...

Thoughts on storage devices

in 1024 Byte blocks, we can fit 22 datasets
  assuming that one dataset does not cross block boundaries
  leaving 34 Byte free space in each 1k block

45 Byte per dataset gives...
  - at 15-minute measurements:
      4 datasets per hour
      96 datasets per day
      2016 datasets per three-week vacation
      35136 datasets per 366-day year (1581120 Byte)

      1598 1kB blocks would hold 35156 datasets.

   - at 5-minute measurements:
      105408 datasets per year

      4792 1kB blocks can hold 105424 datasets.

So, we can decide whether to go for a 2MB or 4MB storage device and are well equipped for just about everything. The regular vacation usage, however, will only needs three weeks of 15 minute data (if not 30 inute) - this could be done in 92 1kB blocks holding 2024 datasets.

Currently I plan to use the AT45DB161D 16Mbit flash memory, covering a Vcc range of 2.7-3.6V (which is within my GPS operating voltage of 3.3V. This is good as I hope to need only two voltages on the device, 5V for the USB interface and 3.3V for the rest...)

Logbook

Last page update: 2009-12-31