Changeset 7552


Ignore:
Timestamp:
08/02/18 20:17:33 (4 months ago)
Author:
kohler
Message:

k2mi_report_params() now adds 1024 weeks to gpsLastLockTime for times between 11/15/1998 and 7/1/2017. This corrects the 1024 week GPS timing error. The Northern California Seismic Network monitors gpsLastLockTime using SeisnetWatch?. - Will Kohler 8/2/2018

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/data_sources/k2ew/k2misc.c

    r6803 r7552  
    300300 
    301301/* returns -1 if str not found anywhere in buf, or position of first char of str */ 
    302 char * find_string_(char* buf, char * str, int buf_len)  
     302char * find_string_(char* buf, char * str, int buf_len) 
    303303{ 
    304304int i; 
     
    317317} 
    318318 
    319 /* returns -1 if MODEM not in buf, or position of first char of MODEM string if found  
     319/* returns -1 if MODEM not in buf, or position of first char of MODEM string if found 
    320320        This was written because the raw data stream could have 0s in it which would 
    321321        nullify the strstr test! */ 
     
    432432            logit("et", "k2mi_force_blkmde: modem in control! not forcing block mode.\n"); 
    433433          /* for now, just exit and let the modem do its thing till its done */ 
    434           return K2R_ERROR;  
     434          return K2R_ERROR; 
    435435          /* later we need to check a config setting if modems should be allowed to take precedent */ 
    436436        } 
     
    442442 
    443443        /* check if returned data contains monitor-mode prompt ('*') */ 
    444         if ( strchr((char *)g_k2mi_buff, (int)'*') != NULL || find_PROMPT((char *)g_k2mi_buff,dcnt)!=NULL) {  
     444        if ( strchr((char *)g_k2mi_buff, (int)'*') != NULL || find_PROMPT((char *)g_k2mi_buff,dcnt)!=NULL) { 
    445445          if (gcfg_debug > 2) 
    446446            logit("et", "k2mi_force_blkmde: received:  command prompt\n"); 
     
    455455    } 
    456456    while(--monmde_count);         /* loop if count not expired */ 
    457   
     457 
    458458    /* for tests to see if sending BLOCK at the end works, fire it in regardless of prompt 2007.12.05 */ 
    459459    prompt_flag=1;  /* paulf 2007.12.05 */ 
     
    480480/*                                                             */ 
    481481/*    block_mode_started++; */ /* this is for when we alternated testing, could be removed 2007.12.05 */ 
    482     }  
     482    } 
    483483    if (!prompt_flag) { 
    484484      logit("et", "k2mi_init_blkmde: no command prompt received, failed to go into block mode\n"); 
     
    844844    /* If flash memory error is detected, send msg to statmgr */ 
    845845    /* Added in version 2.26 by W Kohler, added station name to message in 2.35  */ 
    846     if ( strncmp((char *)databuff, "pcdrv_raw_read, error", 21) == 0 )  
     846    if ( strncmp((char *)databuff, "pcdrv_raw_read, error", 21) == 0 ) 
    847847    { 
    848848       sprintf(g_msg, "K2 <%s>: pcdrv_raw_read error (possibly bad flash memory)", 
     
    995995    if (gcfg_on_batt && rep_on_batt == 0) 
    996996    { 
    997     sprintf(g_msg, "K2 <%s>: lost external power; battery voltage: %0.1f V",  
     997    sprintf(g_msg, "K2 <%s>: lost external power; battery voltage: %0.1f V", 
    998998                g_stnid, batv); 
    999999    k2mi_status_hb(g_error_ltype, K2STAT_ON_BATT, g_msg); 
     
    10171017      && batv < 0.1 * gcfg_battery_alarm) 
    10181018  { 
    1019     sprintf(g_msg, "K2 <%s>: low battery voltage: %0.1f V",  
     1019    sprintf(g_msg, "K2 <%s>: low battery voltage: %0.1f V", 
    10201020                g_stnid, batv); 
    10211021    k2mi_status_hb(g_error_ltype, K2STAT_LOW_BATT, g_msg); 
     
    10751075      if ( gcfg_disk_alarm[index] > 0.0 && rep_disk[index] == 0) 
    10761076      { 
    1077         sprintf(msg2, "K2 <%s>: disk %c failure",  
     1077        sprintf(msg2, "K2 <%s>: disk %c failure", 
    10781078                g_stnid, disk[index]); 
    10791079        k2mi_status_hb(g_error_ltype, K2STAT_BAD_DISK, msg2); 
     
    11571157  time_t timevar; 
    11581158  char msg[200]; 
    1159    
     1159 
    11601160  /* The extended status structure is not byte-aligned for Sparc or Intel * 
    11611161   * hardware. So we have to copy out the bytes into dummy variables      * 
     
    12251225 
    12261226  if (ext_size == EXT_SIZE) return; 
    1227    
     1227 
    12281228  /* Report additional information in the "extended" extended status packet */ 
    12291229 
     
    12701270  short temp; 
    12711271 
     1272  /* gpsRollover: 1024 weeks in seconds */ 
     1273  /* timevar1: temp val holding k2 gps time */ 
     1274  /* timevar2: temp val holding gps time + offset */ 
     1275  unsigned long gpsRollover, timevar1, timevar2; 
     1276 
     1277  /* Fix time if between Nov 15 1998 and Jul 1 2017 */ 
     1278  /* Add 1024 weeks */ 
     1279  gpsRollover = 619315200; 
     1280  timevar1 = (BYTESWAP_UINT32(pk2hdr->roParms.timing.gpsLastLockTime[0]) + K2_TIME_CONV); 
     1281  /* info: logit("et", "K2 gpsLastLockTime: %d\n", timevar1); */ 
     1282  if (timevar1 > 911088000 && timevar1 < 1498867200 ) 
     1283  { 
     1284    timevar2 = BYTESWAP_UINT32(timevar1 + gpsRollover - K2_TIME_CONV); 
     1285    /* modify recent (lowest addr) and previous recordings */ 
     1286    pk2hdr->roParms.timing.gpsLastLockTime[0] = timevar2; 
     1287    /* correct previously recorded time */ 
     1288    timevar1 = BYTESWAP_UINT32(pk2hdr->roParms.timing.gpsLastLockTime[1]); 
     1289    timevar2 = BYTESWAP_UINT32(timevar1 + gpsRollover); 
     1290    pk2hdr->roParms.timing.gpsLastLockTime[1] = timevar2; 
     1291  } 
     1292 
    12721293/* Write K2 header to a disk file 
    12731294   ******************************/ 
     
    12961317  if ((int)temp < gcfg_templo_alarm && rep_temp == 0) 
    12971318  { 
    1298     sprintf(g_msg, "K2 <%s>: low temperature: %d.%1d C",  
     1319    sprintf(g_msg, "K2 <%s>: low temperature: %d.%1d C", 
    12991320                g_stnid, temp / 10, temp % 10); 
    13001321    k2mi_status_hb(g_error_ltype, K2STAT_LOW_TEMP, g_msg); 
     
    13031324  else if ((int)temp > gcfg_temphi_alarm && rep_temp == 0) 
    13041325  { 
    1305     sprintf(g_msg, "K2 <%s>: high temperature: %d.%1d C",  
     1326    sprintf(g_msg, "K2 <%s>: high temperature: %d.%1d C", 
    13061327                g_stnid, temp / 10, temp % 10); 
    13071328    k2mi_status_hb(g_error_ltype, K2STAT_HIGH_TEMP, g_msg); 
     
    13101331  else if (rep_temp == 1) 
    13111332  { 
    1312     sprintf(g_msg, "K2 <%s>: temperature OK: %d.%1d C",  
     1333    sprintf(g_msg, "K2 <%s>: temperature OK: %d.%1d C", 
    13131334                g_stnid, temp / 10, temp % 10); 
    13141335    k2mi_status_hb(g_error_ltype, K2STAT_OK_TEMP, g_msg); 
     
    13501371            if ( prev_gpslock == 1 ) 
    13511372            { 
    1352                sprintf(g_msg, "K2 <%s>: No GPS lock for %.1lf hours.",  
     1373               sprintf(g_msg, "K2 <%s>: No GPS lock for %.1lf hours.", 
    13531374                        g_stnid, timeSinceLastLock ); 
    13541375               k2mi_status_hb(g_error_ltype, K2STAT_GPSLOCK, g_msg); 
     
    13581379         else 
    13591380         { 
    1360             if ( prev_gpslock == 0 )  
     1381            if ( prev_gpslock == 0 ) 
    13611382            { 
    13621383               sprintf(g_msg, "K2 <%s>: GPS lock acquired.", g_stnid); 
Note: See TracChangeset for help on using the changeset viewer.