00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include <stdlib.h>
00024 #include <stdio.h>
00025 #include <time.h>
00026 #include <ctype.h>
00027 #include <math.h>
00028 #include <errno.h>
00029 #include <unistd.h>
00030 #include <string.h>
00031 #include <sys/types.h>
00032 #include <sys/stat.h>
00033 #include <fcntl.h>
00034
00035 #include "common.h"
00036
00037 int releaseWarned=0;
00038
00040 void CheckSoftwareRelease(void)
00041 {
00042 int rel,dsp;
00043
00044 if (strcmp(oldHWConfig.softwareRealease,HWConfig.softwareRealease))
00045 {
00046
00047 releaseWarned=0;
00048 }
00049
00050 if (0==strncmp(HWConfig.softwareRealease,"TITAN",5))
00051
00052 {
00053
00054 rel=strtoul(HWConfig.softwareRealease+5,NULL,16);
00055 if ((rel>=0x40F)&&(rel<=0x506))
00056 {
00057
00058 if (!releaseWarned)
00059 {
00060 releaseWarned=1;
00061 PrintWarning("this station is running "
00062 "a Titan software [%s] "
00063 "subject to timing error. "
00064 "Contact Agecodagis.\n",
00065 HWConfig.softwareRealease);
00066 }
00067 }
00068
00069 }
00070
00071 if (
00072 (HWConfig.softwareRealease[0]=='D')&&
00073 (HWConfig.softwareRealease[5]=='A')
00074 )
00075
00076 {
00077 sscanf(HWConfig.softwareRealease+1,"%d",&dsp);
00078
00079 if (0==sscanf(HWConfig.softwareRealease+6,"%d",&rel))
00080 {
00081 rel=-1;
00082 }
00083 else
00084 {
00085
00086 if (rel<6)
00087 {
00088 HWConfig.digitizer.ok=1;
00089 HWConfig.digitizer.adcFrequency=16000;
00090 HWConfig.digitizer.adcDecimation=8;
00091 HWConfig.digitizer.adcDecimationLength=128;
00092 HWConfig.digitizer.adcId=10;
00093 HWConfig.digitizer.secondDecimationLength=127;
00094 HWConfig.digitizer.adcDelay=2.5;
00095 }
00096 }
00097
00098 }
00099 }
00100
00101 struct DigitizerType titan1Digit[4] = {
00102 { 0, 0, 0, 0, CS5323, 29., 0 },
00103 { 0, 0, 0, 0, AD7710, 1.5, 0 },
00104 { 0, 0, 0, 0, HI7190, 1.5, 0 },
00105 { 0, 0, 0, 0, CS5321, 29., 0 }
00106 };
00107
00109 void UpdateTitan1ADCInfo(void)
00110 {
00111 int i;
00112 switch (HWConfig.digitizer.adcId)
00113 {
00114 case CS5321:
00115 HWConfig.LSB=596.;
00116 HWConfig.impedance=25000.0;
00117 for (i=0; i<4; i++) HWConfig.gain[i]=1;
00118 break;
00119 case CS5323:
00120 HWConfig.LSB=843.;
00121 HWConfig.impedance=25000.0;
00122 for (i=0; i<4; i++) HWConfig.gain[i]=1;
00123 break;
00124 case AD7710:
00125 HWConfig.LSB=298.0;
00126 HWConfig.impedance=25000.0;
00127 for (i=0; i<4; i++) HWConfig.gain[i]=1;
00128 break;
00129 case HI7190:
00130 HWConfig.LSB=729.0;
00131 HWConfig.impedance=25000.0;
00132 HWConfig.gain[0]=1;
00133 HWConfig.gain[1]=2;
00134 HWConfig.gain[2]=4;
00135 HWConfig.gain[3]=8;
00136 HWConfig.gain[4]=16;
00137 for (i=0; i<5; i++)
00138 {
00139 if ((1<<HWConfig.info5.gain)==HWConfig.gain[i])
00140 {
00141 int j;
00142 for (j=0; j<MAX_OSIRIS_CHANNEL; j++)
00143 {
00144 HWConfig.selectedGain[j]=i;
00145 }
00146 break;
00147 }
00148 }
00149 break;
00150 }
00151 }
00152
00157 unsigned char ProcessInfoFrame(const unsigned char *frame)
00158 {
00159
00160 if ((frame[10]>0)&&(frame[10]<32))
00161 {
00162 memcpy(HWConfig.infoFrame[frame[10]],frame,12);
00163 }
00164
00165 switch (frame[10])
00166 {
00167 case 0:
00168 case 1:
00169 case 2:
00170 case 3:
00171 HWConfig.info03[frame[10]].ch=frame[10];
00172 HWConfig.info03[frame[10]].lta=frame2i24(frame,0);
00173 HWConfig.info03[frame[10]].sta=frame2i24(frame,3);
00174 HWConfig.info03[frame[10]].srCode=frame[6]&0xff;
00175 HWConfig.info03[frame[10]].threshold=frame[7]&0xff;
00176 HWConfig.info03[frame[10]].active=frame[8]&0xff;
00177 HWConfig.info03[frame[10]].offset=frame[9]&0xff;
00178 break;
00179 case 5:
00180 HWConfig.info5.preEvent=frame2i16(frame,0);
00181 HWConfig.info5.postEvent=frame2i16(frame,2);
00182 HWConfig.info5.gain=frame[4]&0xff;
00183 HWConfig.info5.endDuration=frame2i16(frame,5);
00184 HWConfig.info5.cycles=frame[7]&0xff;
00185 HWConfig.info5.endDurationMode=frame[8]&0xff;
00186 case 7:
00187 memset(HWConfig.fieldIdent,0,10);
00188 strncpy(HWConfig.fieldIdent,(char *)frame,9);
00189 if (manualStationName[0]!=0)
00190 {
00191 strcpy(HWConfig.fieldIdent,manualStationName);
00192 }
00193 break;
00194 case 15:
00195 HWConfig.info15.time=(int)(frame2i32_64(frame,0));
00196 HWConfig.info15.pulseLength=frame2i16(frame,4);
00197 HWConfig.info15.pulseTest=frame[6]&0xff;
00198 HWConfig.info15.PPM=frame[7]&0xff;
00199 HWConfig.info15.reboot=frame[8]&0xff;
00200 if (frame[8]&1)
00201 {
00202 HWConfig.rebootTime.usecond=((int64_t)HWConfig.info15.time)<<32;
00203 }
00204 else
00205 {
00206 HWConfig.resetTime.usecond=((int64_t)HWConfig.info15.time)<<32;
00207 }
00208 break;
00209 case 16:
00210 memset(HWConfig.serialNumber,0,10);
00211 strncpy(HWConfig.serialNumber,(char *)frame,9);
00212 break;
00213 case 17:
00214 memset(HWConfig.softwareRealease,0,10);
00215 strncpy(HWConfig.softwareRealease,(char *)frame,9);
00216 CheckSoftwareRelease();
00217 break;
00218 case 18:
00219 HWConfig.info18.mediaBytes=frame2i32(frame,2)>>(20-15);
00220 HWConfig.info18.batteryVoltage=
00221 20.163*(float)(frame[6])/256.;
00222 HWConfig.info18.detections=frame2i16(frame,0);
00223 HWConfig.info18.lostFlushLowBatt=frame2i16(frame,7);
00224 break;
00225 case 19:
00226 HWConfig.info19.lostFlushMediumError=frame2i16(frame,0);
00227 HWConfig.info19.flashCycles=frame[2]&0xff;
00228 HWConfig.info19.flashBytes=frame2i24(frame,3);
00229 HWConfig.info19.flushState=frame[6]&0xff;
00230 HWConfig.info19.triggerInProcess=frame[7]&0xff;
00231 HWConfig.info19.mediumError=frame[8]&0xff;
00232 HWConfig.info19.flushRunning=frame[9]&0xff;
00233 break;
00234 case 20:
00235 HWConfig.info20.channels=frame[0]&0xff;
00236 HWConfig.info20.ADCType=frame[1]&0x7;
00237 HWConfig.info20.auxPresent=frame[1]&(1<<7);
00238 HWConfig.info20.radioMode=frame[2]&(1<<0);
00239 HWConfig.info20.continuousGPS=frame[2]&(1<<1);
00240 HWConfig.info20.samplingSet=(frame[3]&(1<<2))?160:250;
00241 HWConfig.info20.recordingMode=frame[5]&(1<<0);
00242 HWConfig.info20.recordingMedium=((frame[5]>>1)&0x7);
00243 HWConfig.info20.flashSize=frame[6]&0xff;
00244 HWConfig.info20.mediumSize=frame[7]&0xff;
00245 HWConfig.info20.internalInfo1=frame[8]&0xff;
00246 HWConfig.info20.parallelLink=frame[9]&0xff;
00247 if (HWConfig.digitizer.ok)
00248 {
00249 break;
00250 }
00251
00252 switch (frame[1]&0x7)
00253 {
00254 case 0:
00255 case 1:
00256 case 2:
00257 case 3:
00258 HWConfig.digitizer.adcDecimationLength=1;
00259 HWConfig.digitizer.adcId=
00260 titan1Digit[frame[1]&0x7].adcId;
00261 HWConfig.digitizer.adcDelay=
00262 titan1Digit[frame[1]&0x7].adcDelay;
00263 UpdateTitan1ADCInfo();
00264 HWConfig.digitizer.ok=1;
00265 break;
00266 }
00267 break;
00268 case 30:
00269 HWConfig.avgPos.lat=(float)(frame2i32(frame,0))*180.e-8/MY_PI;
00270 HWConfig.avgPos.lon=(float)(frame2i32(frame,4))*180.e-8/MY_PI;
00271 break;
00272 case 31:
00273 HWConfig.avgPos.elev=(float)(frame2i32(frame,0))*0.01;
00274 break;
00275 }
00276 return(0);
00277 }