Changeset 55 in ntrip for trunk/BNC/RTIGS
- Timestamp:
- Aug 20, 2006, 9:30:54 PM (18 years ago)
- Location:
- trunk/BNC/RTIGS
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/RTIGS/rtigs.cpp
r54 r55 1 1 #include "rtigs.h" 2 2 3 #define MAXSTREAM 2048 3 #define MAXSTREAM 10000 4 5 //////////////////////////////////////////////////////////////////////////// 6 void SwitchBytes( char *Start, int Size ) { 7 char Tmp; 8 char *End = Start + Size - 1; 9 for( Tmp = *Start; Start < End; Tmp = *Start ){ 10 *Start++ = *End; 11 *End-- = Tmp; 12 } 13 } 4 14 5 15 int main() { … … 20 30 21 31 // use something like recvfrom 22 23 messType = GPSTrans.GetRTIGSHdrRecType(data_stream); 24 numbytes = GPSTrans.GetRTIGSHdrRecBytes(data_stream); 25 statID = GPSTrans.GetRTIGSHdrStaID(data_stream); 26 27 switch (messType) { 28 case 100: 29 GPSTrans.Decode_RTIGS_Sta(data_stream, numbytes , rtigs_sta); 30 break; 31 case 200: 32 retval = GPSTrans.Decode_RTIGS_Obs(data_stream, numbytes , rtigs_obs); 33 if (retval >= 1) { 34 GPSTrans.print_CMEAS(); 35 } 36 break; 37 case 300: 38 retval = GPSTrans.Decode_RTIGS_Eph(data_stream, numbytes , rtigs_eph, PRN); 39 break; 40 case 400: 41 retval = GPSTrans.Decode_RTIGS_Met(data_stream, numbytes , &rtigs_met); 42 break; 32 FILE* inpFile = fopen("RTIGS.txt", "rb"); 33 34 while (true) { 35 size_t nr = 0; 36 if (inpFile) { 37 nr = fread(data_stream, sizeof(unsigned char), MAXSTREAM, inpFile); 38 if (nr == 0) exit(0); 39 cout << "Number of bytes read: " << nr << endl; 40 } 41 else { 42 exit(1); 43 } 44 45 // Find the beginning of the message 46 // --------------------------------- 47 size_t sz = sizeof(unsigned short); 48 bool found = false; 49 size_t ii; 50 for (ii = 0; ii < nr - sz; ii += sz) { 51 unsigned short xx; 52 memcpy( (void*) &xx, &data_stream[ii], sz); 53 SwitchBytes( (char*) &xx, sz); 54 if (xx == 200) { 55 found = true; 56 break; 57 } 58 } 59 if (! found) { 60 cout << "Message not found\n"; 61 exit(0); 62 } 63 else { 64 cout << "Message found at " << ii << endl; 65 } 66 67 68 messType = GPSTrans.GetRTIGSHdrRecType(&data_stream[ii]); 69 numbytes = GPSTrans.GetRTIGSHdrRecBytes(&data_stream[ii]); 70 statID = GPSTrans.GetRTIGSHdrStaID(&data_stream[ii]); 71 72 cout << "messType " << messType << endl; 73 cout << "numbytes " << numbytes << endl; 74 cout << "statID " << statID << endl; 75 76 switch (messType) { 77 case 100: 78 GPSTrans.Decode_RTIGS_Sta(&data_stream[ii], numbytes , rtigs_sta); 79 break; 80 case 200: 81 retval = GPSTrans.Decode_RTIGS_Obs(&data_stream[ii], numbytes , rtigs_obs); 82 if (retval >= 1) { 83 GPSTrans.print_CMEAS(); 84 } 85 break; 86 case 300: 87 retval = GPSTrans.Decode_RTIGS_Eph(&data_stream[ii], numbytes , rtigs_eph, PRN); 88 break; 89 case 400: 90 retval = GPSTrans.Decode_RTIGS_Met(&data_stream[ii], numbytes , &rtigs_met); 91 break; 92 } 43 93 } 44 94 … … 125 175 } 126 176 127 //128 ////////////////////////////////////////////////////////////////////////////129 void CGPS_Transform::SwitchBytes( char *Start, int Size ) {130 char Tmp;131 char *End = Start + Size - 1;132 for( Tmp = *Start; Start < End; Tmp = *Start ){133 *Start++ = *End;134 *End-- = Tmp;135 }136 }137 177 138 178 // … … 556 596 StrPos = IGSObsMinusPtr = sizeof(RTIGSO_T) - sizeof (rtigs_obs.data); 557 597 598 cout << "StrPos " << StrPos << endl; 599 558 600 memcpy ((void *)&rtigs_obs.rec_id, RTIGSO_Str, IGSObsMinusPtr); 559 601 … … 564 606 565 607 566 // printf("RecNumber : %hd Station ID %hd Num Obs %hd NumBytes %hd\n",rtigs_obs.rec_id, rtigs_obs.sta_id, rtigs_obs.num_obs, rtigs_obs.num_bytes); 608 printf("RecNumber : %hd Station ID %hd Num Obs %hd NumBytes %hd\n",rtigs_obs.rec_id, rtigs_obs.sta_id, rtigs_obs.num_obs, rtigs_obs.num_bytes); 609 567 610 if((rtigs_obs.rec_id == 200) && (rtigs_obs.num_obs <= MAXCHANNELS_FOR_SOCKETS_TYPE1)) 568 611 { -
trunk/BNC/RTIGS/rtigs.h
r52 r55 109 109 short P1_P2_Block_Extract(char * P1P2Str, double CA, double &Rng , double &Phase, double &RngF2Delta,short decode_F1orF2Flag );//done 110 110 unsigned long JPL_xtractLongVal (unsigned startBitNbr, unsigned xtractNbrBits, const char *msg); //done 111 void SwitchBytes( char *Start, int Size );112 111 inline void SwitchIGS_Sta_HdrBytes( RTIGSS_T *StaHdr); 113 112 inline void SwitchIGS_Obs_HdrBytes( RTIGSO_T *ObsHdr);
Note:
See TracChangeset
for help on using the changeset viewer.