//mikhailov : //reading and updating of time sync information #include "descript.h" #include "CRC.h" //int RTtoMT,RT,Timesync,OBTtimesync; // Resurs time to moscow, Resurs time, ... extern int print_flag; extern long int Timesync; extern long int OBTtimesync; extern char timesync[120]; void RunHeaderReader(char *packet) { // long int time=0; /*PAMELA packet time*/ // long int temp=0; int j,k; FILE *ftime_sync; long int dataLength; long int length; // short version of unpacling!!!! only time /* long int RM_ACQ_SETTING_MODE, FAVOURITE_WORKING_SCHEDULE, EFFECTIVE_WORKING_SCHEDULE, PRH_VAR_TRIGGER_MODE_A, PRH_VAR_TRIGGER_MODE_B, RM_ACQ_AFTER_CALIB ;*/ UINT32 OBT_TIME_SYNC, LAST_TYME_SYNC_INFO; /* time=(long int)(unsigned char)(packet[11])+ 256*(long int)(unsigned char)(packet[10])+ 256*256*(long int)(unsigned char)(packet[9])+ 256*256*256*(long int)(unsigned char)(packet[8]); temp=(long int)(unsigned char)(packet[7])+ 256*(long int)(unsigned char)(packet[6])+ 256*256*(long int)(unsigned char)(packet[5]); */ /*unpacking several packets.... mikhailov unpackingPamelaPacket(packet,type) */ length=(long int)(unsigned char)(packet[14])+ 256*(long int)(unsigned char)(packet[13])+ 256*256*(long int)(unsigned char)(packet[12]); //if (print_flag>0)cout<<"length="<read(subData, sizeof(subData)); for (j=0;j0) printf("crc Cal Read %x %x %x\n",calCRC,readCRC,(((UINT16)subData[length-1])&0x00FF)); // test of program : !!!!!!!!!!!!! // calCRC = CM_Compute_CRC16(0,(BYTE)subData, dataLength); calCRC=readCRC; // !!!!!!!!!!!!!!!!!!!!!!!!!!!!! // if (print_flag>0) printf("crc %x %x\n",calCRC,readCRC); //took the final CRC to compare it with the previous calculated CRC of the data // cout<0) cout<0){ for (k=0;k<8;k++) cout<<(UINT32)packet[k+5+16]<<"\n";}; k=16; OBT_TIME_SYNC = (((UINT32)packet[5+k]<<24)&0xFF000000) + (((UINT32)packet[6+k]<<16)&0x00FF0000) + (((UINT32)packet[7+k]<<8)&0x0000FF00) + (((UINT32)packet[8+k])&0x000000FF); LAST_TYME_SYNC_INFO = (((UINT32)packet[9+k]<<24)&0xFF000000) + (((UINT32)packet[10+k]<<16)&0x00FF0000) + (((UINT32)packet[11+k]<<8)&0x0000FF00) + (((UINT32)packet[12+k])&0x000000FF); // FAVOURITE_WORKING_SCHEDULE = (BYTE)packet[25]; // EFFECTIVE_WORKING_SCHEDULE = (BYTE)packet[26]; // PRH_VAR_TRIGGER_MODE_A = (((UINT32)packet[27]<<24)&0xFF000000) + (((UINT32)packet[28]<<16)&0x00FF0000) + (((UINT32)packet[29]<<8)&0x0000FF00) + (((UINT32)packet[30])&0x000000FF); // PRH_VAR_TRIGGER_MODE_B = (((UINT32)packet[31]<<24)&0xFF000000) + (((UINT32)packet[32]<<16)&0x00FF0000) + (((UINT32)packet[33]<<8)&0x0000FF00) + (((UINT32)packet[34])&0x000000FF); // RM_ACQ_AFTER_CALIB = (BYTE)packet[35]; // if (print_flag>0) cout<OBT_TIME_SYNC = (((UINT32)subData[5]<<24)&0xFF000000) + (((UINT32)subData[6]<<16)&0x00FF0000) + (((UINT32)subData[7]<<8)&0x0000FF00) + (((UINT32)subData[8])&0x000000FF); // RunHeader->LAST_TIME_SYNC_INFO = (((UINT32)subData[9]<<24)&0xFF000000) + (((UINT32)subData[10]<<16)&0x00FF0000) + (((UINT32)subData[11]<<8)&0x0000FF00) + (((UINT32)subData[12])&0x000000FF); // mikhailov 06.12.2004 if ((ftime_sync=fopen(timesync,"a+"))==NULL) { printf("Can not open timesync.dat file. \n"); exit(1); } Timesync=LAST_TYME_SYNC_INFO; OBTtimesync=OBT_TIME_SYNC; extern long int RTtoMT; extern long int RT; fprintf(ftime_sync,"%u %u %u %u\n",RTtoMT,RT,OBTtimesync,Timesync); // read for initial information for time synchronization if (print_flag>0) {cout<