5 |
#include "CRC.h" |
#include "CRC.h" |
6 |
//int RTtoMT,RT,Timesync,OBTtimesync; // Resurs time to moscow, Resurs time, ... |
//int RTtoMT,RT,Timesync,OBTtimesync; // Resurs time to moscow, Resurs time, ... |
7 |
|
|
8 |
|
extern int print_flag; |
9 |
extern long int Timesync; |
extern long int Timesync; |
10 |
extern long int OBTtimesync; |
extern long int OBTtimesync; |
11 |
void RunHeaderReader(char *packet) |
void RunHeaderReader(char *packet) |
47 |
temp=(long int)(unsigned char)(packet[7])+ |
temp=(long int)(unsigned char)(packet[7])+ |
48 |
256*(long int)(unsigned char)(packet[6])+ |
256*(long int)(unsigned char)(packet[6])+ |
49 |
256*256*(long int)(unsigned char)(packet[5]); |
256*256*(long int)(unsigned char)(packet[5]); |
50 |
if (fmod((float)(temp),(float)(10000.))==0.) |
if ((fmod((float)(temp),(float)(10000.))==0.)&&(print_flag>0)) cout<<"sorting "<<temp<<"\n"; |
|
cout<<"sorting "<<temp<<"\n"; |
|
51 |
/*unpacking several packets.... mikhailov |
/*unpacking several packets.... mikhailov |
52 |
unpackingPamelaPacket(packet,type) */ |
unpackingPamelaPacket(packet,type) */ |
53 |
length=(long int)(unsigned char)(packet[14])+ |
length=(long int)(unsigned char)(packet[14])+ |
70 |
InputFile->read(subData, sizeof(unsigned char)*dataLength); */ |
InputFile->read(subData, sizeof(unsigned char)*dataLength); */ |
71 |
|
|
72 |
calCRC = CM_Compute_CRC16(0, (unsigned char*)subData, dataLength); |
calCRC = CM_Compute_CRC16(0, (unsigned char*)subData, dataLength); |
73 |
printf("crc %x %x\n",calCRC,readCRC); |
if (print_flag>0) printf("crc %x %x\n",calCRC,readCRC); |
74 |
//took the final CRC to compare it with the previous calculated CRC of the data |
//took the final CRC to compare it with the previous calculated CRC of the data |
75 |
|
|
76 |
// for(j=0;j<length;j++) printf("crc %x \n",(BYTE)subData[j]); |
// for(j=0;j<length;j++) printf("crc %x \n",(BYTE)subData[j]); |
77 |
|
|
78 |
// cout<<calCRC<<" =crc ?="<<readCRC<<"\n"; |
// cout<<calCRC<<" =crc ?="<<readCRC<<"\n"; |
79 |
if (calCRC == readCRC) {cout<<calCRC<<" =crc ok="<<"\n"; |
if ((calCRC == readCRC)&&(print_flag>0)) {cout<<calCRC<<" =crc ok="<<"\n"; |
80 |
|
|
81 |
RM_ACQ_SETTING_MODE = (BYTE)packet[16]; |
RM_ACQ_SETTING_MODE = (BYTE)packet[16]; |
82 |
OBT_TIME_SYNC = (((UINT32)packet[21]<<24)&0xFF000000) + (((UINT32)packet[22]<<16)&0x00FF0000) + (((UINT32)packet[23]<<8)&0x0000FF00) + (((UINT32)packet[24])&0x000000FF); |
OBT_TIME_SYNC = (((UINT32)packet[21]<<24)&0xFF000000) + (((UINT32)packet[22]<<16)&0x00FF0000) + (((UINT32)packet[23]<<8)&0x0000FF00) + (((UINT32)packet[24])&0x000000FF); |
86 |
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_A = (((UINT32)packet[27]<<24)&0xFF000000) + (((UINT32)packet[28]<<16)&0x00FF0000) + (((UINT32)packet[29]<<8)&0x0000FF00) + (((UINT32)packet[30])&0x000000FF); |
87 |
PRH_VAR_TRIGGER_MODE_B = (((UINT32)packet[31]<<24)&0xFF000000) + (((UINT32)packet[32]<<16)&0x00FF0000) + (((UINT32)packet[33]<<8)&0x0000FF00) + (((UINT32)packet[34])&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); |
88 |
RM_ACQ_AFTER_CALIB = (BYTE)packet[35]; |
RM_ACQ_AFTER_CALIB = (BYTE)packet[35]; |
89 |
cout<<OBT_TIME_SYNC<<" = ="<<LAST_TYME_SYNC_INFO<<"\n"; |
if (print_flag>0) cout<<OBT_TIME_SYNC<<" = ="<<LAST_TYME_SYNC_INFO<<"\n"; |
90 |
|
|
91 |
|
|
92 |
|
|
99 |
extern long int RT; |
extern long int RT; |
100 |
fprintf(ftime_sync,"%u %u %u %u\n",RTtoMT,RT,OBTtimesync,Timesync); |
fprintf(ftime_sync,"%u %u %u %u\n",RTtoMT,RT,OBTtimesync,Timesync); |
101 |
// read for initial information for time synchronization |
// read for initial information for time synchronization |
102 |
|
if (print_flag>0) |
103 |
cout<<RTtoMT<<"\n"; |
{cout<<RTtoMT<<"\n"; |
104 |
cout<<RT<<"\n"; |
cout<<RT<<"\n"; |
105 |
cout<<Timesync<<"\n"; |
cout<<Timesync<<"\n"; |
106 |
cout<<OBTtimesync<<"\n"; |
cout<<OBTtimesync<<"\n"; |
107 |
|
} |
108 |
|
|
109 |
|
|
110 |
fclose(ftime_sync);} |
fclose(ftime_sync);} |