file: spncflash.html
8 Aug 2007

CompactFLASH CARD STORAGE - SPN1 SWR

The following describes the data storage and record format of CompactFLASH memory cards used in ASIMET instrumentation with Ver4.xx and later firmware.

CompactFLASH card sectors of interest:


Description of SPN1 SWR data file beginning at Sector 322

The CFLASH data file (yourname.DAT) consumes most of the CompactFLASH card. Each record is 512 bytes long, containing the date and time written, 60 minutes of IEEE single-precision TOTAL shortwave radiation data, 60 minutes of IEEE single-precision DIFFUSE shortwave radiation data, a flag which is set to 0xA5A5 when the record is written, and a 2 byte CRC of the previous 510 bytes. The actual C language struct is reproduced here to show the format of the stored image.

   /* this is the SPN1 SWR data record structure, 512 bytes */
   struct SWR_record
      {
      struct time_type time1;      /* 8 bytes of time */
      float swr_total[60];         /* 60 minutes of SPN1 total data */
      float swr_diffuse[60];       /* 60 minutes of SPN1 diffuse data */
      unsigned char unused[20];
      unsigned short used;     /* set to 0xA5A5 upon record write */
      unsigned short swr_CRC;  /* CRC of previous 510 bytes */
      };


struct time_type { unsigned char hour; unsigned char min; unsigned char sec; unsigned char day; unsigned char dow; /* day of week - NOT USED */ unsigned char mon; unsigned short int year; };

Note that time structure is NOT ANSI-compatible.

The offsets and sizes of the record components is shown below. Remember that the first SWR record is stored at Sector 322 in the CompactFLASH card.

   byte #  size    name          comment
     0      8       time        8 bytes of time
     8      4       swr_total0]   minute 0 SWR TOTAL data
    12      4       swr_total[1]   minute 1 SWR TOTAL data
      .
      .
      .
   240      4       swr_total[58]   minute 58 SWR TOTAL data
   244      4       swr_total[59]   minute 59 SWR TOTAL data
   248      4       swr_diffuse[0]  minute 0 SWR DIFFUSE data
   252      4       swr_diffuse[1]   minute 1 SWR DIFFUSE data
      .
      .
      .
   480      4       swr_diffuse[58]   minute 58 SWR DIFFUSE data
   484      4       swr_diffuse[59]   minute 59 SWR DIFFUSE data
   488     20       reserved
   508      2       used flag set to A5A5h when record is written
   510      2       swr_CRC      CRC of previous 510 bytes

Data is written to the FLASH card immediately following the acquisition of data at the rollover to the 59th minute of each hour. This is reflected in the time stamp on each record, typically 1 second into minute 59.


*** IMPORTANT NOTE ***

The byte order of the some numeric values stored by the VOSSPN53 firmware is reversed relative to Intel-based PC's. That is, a long integer (4 bytes) or short integer (2 bytes) stored by a PC will be LS byte first in memory, and floats with mantissa first. The VOSSPN53 firmware stores shorts and longs with MS byte first in memory. Also, single precision IEEE float values are big-endian. This must be accounted for when processing the data. See the float storage format below.


The "used" flag value is used to simplify finding the end of valid records the .DAT file; as each record is written, the "used" flag is set to A5A5h to provide a distinct pattern to search on for good records.

The CRC is NOT IMPLEMENTED.


"float" 4 byte values are IEEE-754 single-precision float.

Storage format for these float values is as follows:

      byte addr      +0         +1           +2         +3
      contents     SEEEEEEE   EMMMMMMM    MMMMMMMM   MMMMMMMM

            where S => Sign bit;  1 = negative,  0 = positive
                  E => Exponent (2's comp) with offset 127 (decimal)
                  M => 23-bit normal mantissa (highest bit always 1 and
                           therefore not stored)