Changeset 878 in ntrip
- Timestamp:
- May 6, 2008, 4:47:42 PM (17 years ago)
- Location:
- trunk/BNS/RTCM
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNS/RTCM/clock_orbit_rtcm.c
r864 r878 3 3 Name: clock_orbit_rtcm.c 4 4 Project: RTCM3 5 Version: $Id : clock_orbit_rtcm.c,v 1.1 2008/05/04 17:38:12 mervart Exp$5 Version: $Id$ 6 6 Authors: Dirk Stöcker 7 7 Description: state space approach for RTCM3 … … 397 397 while((a) > numbits) \ 398 398 { \ 399 if(!size--) return -2; \399 if(!size--) return GCOBR_SHORTBUFFER; \ 400 400 bitbuffer = (bitbuffer<<8)|((unsigned char)*(buffer++)); \ 401 401 numbits += 8; \ … … 424 424 425 425 /* standard values */ 426 #define G_HEADER SKIPBITS(8+6+10) 426 #define G_HEADER(a) GETBITS(a,8) 427 #define G_RESERVEDH(a) GETBITS(a,6) 428 #define G_SIZE(a) GETBITS(a, 10) 427 429 #define G_MESSAGE_NUMBER(a) GETBITS(a, 12) /* DF002 */ 428 430 #define G_RESERVED6 SKIPBITS(6) /* DF001 */ 429 #define G_GPS_SATELLITE_ID(a) GETBITS(a, 6) /* DF068 */ 431 #define G_GPS_SATELLITE_ID(a) {int temp; GETBITS(temp, 6) \ 432 if(a && a != temp) return GCOBR_DATAMISMATCH; a = temp;} /* DF068 */ 430 433 #define G_GPS_IODE(a) GETBITS(a, 8) /* DF071 */ 431 434 #define G_GLONASS_IOD(a) GETBITS(a, 8) /* DF237 */ … … 433 436 /* defined values */ 434 437 #define G_MULTIPLE_MESSAGE_INDICATOR(a) GETBITS(a, 1) 435 #define G_GPS_EPOCH_TIME(a) GETBITS(a, 20) 436 #define G_GLONASS_EPOCH_TIME(a) GETBITS(a, 17) 437 #define G_GLONASS_SATELLITE_ID(a) GETBITS(a, 6) 438 #define G_NO_OF_SATELLITES(a) GETBITS(a, 5) 438 #define G_GPS_EPOCH_TIME(a, b) {int temp; GETBITS(temp, 20) \ 439 if(b && a != temp) return GCOBR_TIMEMISMATCH; a = temp;} 440 #define G_GLONASS_EPOCH_TIME(a, b) {int temp; GETBITS(temp, 17) \ 441 if(b && a != temp) return GCOBR_TIMEMISMATCH; a = temp;} 442 #define G_GLONASS_SATELLITE_ID(a) {int temp; GETBITS(temp, 6) \ 443 if(a && a != temp) return GCOBR_DATAMISMATCH; a = temp;} 444 #define G_NO_OF_SATELLITES(a) {int temp; GETBITS(temp, 5) \ 445 if(a && a != temp) return GCOBR_DATAMISMATCH; a = temp;} 439 446 #define G_SATELLITE_REFERENCE_POINT(a) GETBITS(a, 1) 440 447 #define G_SATELLITE_REFERENCE_DATUM(a) GETBITS(a, 1) … … 458 465 #define G_CODE_BIAS(a) GETFLOATSIGN(a, 20, 1/100.0) 459 466 460 /* FIXME: Joining data does no care for satellite numbers, dates and so on. 461 It will only work with data, which is stored and the same order and number as 462 the previos blocks! */ 463 464 int GetClockOrbitBias(struct ClockOrbit *co, struct Bias *b, 465 const char *buffer, size_t size) 467 enum GCOB_RETURN GetClockOrbitBias(struct ClockOrbit *co, struct Bias *b, 468 const char *buffer, size_t size, int *bytesused) 466 469 { 467 int type, mmi=0, i, j; 470 int type, mmi=0, i, j, h, rs, sizeofrtcmblock; 471 const char *blockstart = buffer; 468 472 DECODESTART 469 473 470 G_HEADER 474 if(size < 7) 475 return GCOBR_SHORTBUFFER; 476 477 G_HEADER(h) 478 G_RESERVEDH(rs) 479 G_SIZE(sizeofrtcmblock); 480 481 if((unsigned char)h != 0xD3 || rs) 482 return GCOBR_UNKNOWNDATA; 483 if(size < sizeofrtcmblock + 3) /* 3 header bytes already removed */ 484 return GCOBR_MESSAGEEXCEEDSBUFFER; 485 if(CRC24(sizeofrtcmblock+3, (const unsigned char *) blockstart) != 486 ((((unsigned char)buffer[sizeofrtcmblock])<<16)| 487 (((unsigned char)buffer[sizeofrtcmblock+1])<<8)| 488 (((unsigned char)buffer[sizeofrtcmblock+2])))) 489 return GCOBR_CRCMISMATCH; 490 471 491 G_MESSAGE_NUMBER(type) 472 492 switch(type) 473 493 { 474 494 case COTYPE_GPSORBIT: 475 if(!co) return -5;476 G_GPS_EPOCH_TIME(co->GPSEpochTime )495 if(!co) return GCOBR_NOCLOCKORBITPARAMETER; 496 G_GPS_EPOCH_TIME(co->GPSEpochTime, co->NumberOfGPSSat) 477 497 G_MULTIPLE_MESSAGE_INDICATOR(mmi) 478 498 G_RESERVED6 479 499 G_NO_OF_SATELLITES(co->NumberOfGPSSat) 500 if(co->OrbitDataSupplied) 501 return GCOBR_DATAMISMATCH; 480 502 co->OrbitDataSupplied = 1; 481 503 for(i = 0; i < co->NumberOfGPSSat; ++i) … … 497 519 break; 498 520 case COTYPE_GPSCLOCK: 499 if(!co) return -5;500 G_GPS_EPOCH_TIME(co->GPSEpochTime )521 if(!co) return GCOBR_NOCLOCKORBITPARAMETER; 522 G_GPS_EPOCH_TIME(co->GPSEpochTime, co->NumberOfGPSSat) 501 523 G_MULTIPLE_MESSAGE_INDICATOR(mmi) 502 524 G_RESERVED6 503 525 G_NO_OF_SATELLITES(co->NumberOfGPSSat) 526 if(co->ClockDataSupplied) 527 return GCOBR_DATAMISMATCH; 504 528 co->ClockDataSupplied = 1; 505 529 for(i = 0; i < co->NumberOfGPSSat; ++i) … … 514 538 case COTYPE_GPSCOMBINED: 515 539 if(!co) return -5; 516 G_GPS_EPOCH_TIME(co->GPSEpochTime )540 G_GPS_EPOCH_TIME(co->GPSEpochTime, co->NumberOfGPSSat) 517 541 G_MULTIPLE_MESSAGE_INDICATOR(mmi) 518 542 G_RESERVED6 519 543 G_NO_OF_SATELLITES(co->NumberOfGPSSat) 544 if(co->ClockDataSupplied || co->OrbitDataSupplied) 545 return GCOBR_DATAMISMATCH; 520 546 co->OrbitDataSupplied = 1; 521 547 co->ClockDataSupplied = 1; … … 541 567 break; 542 568 case COTYPE_GLONASSORBIT: 543 if(!co) return -5;544 G_GLONASS_EPOCH_TIME(co->GLONASSEpochTime )569 if(!co) return GCOBR_NOCLOCKORBITPARAMETER; 570 G_GLONASS_EPOCH_TIME(co->GLONASSEpochTime, co->NumberOfGLONASSSat) 545 571 G_MULTIPLE_MESSAGE_INDICATOR(mmi) 546 572 G_RESERVED6 547 573 G_NO_OF_SATELLITES(co->NumberOfGLONASSSat) 574 if(co->OrbitDataSupplied) 575 return GCOBR_DATAMISMATCH; 548 576 co->OrbitDataSupplied = 1; 549 577 for(i = CLOCKORBIT_NUMGPS; … … 566 594 break; 567 595 case COTYPE_GLONASSCLOCK: 568 if(!co) return -5;569 G_GLONASS_EPOCH_TIME(co->GLONASSEpochTime )596 if(!co) return GCOBR_NOCLOCKORBITPARAMETER; 597 G_GLONASS_EPOCH_TIME(co->GLONASSEpochTime, co->NumberOfGLONASSSat) 570 598 G_MULTIPLE_MESSAGE_INDICATOR(mmi) 571 599 G_RESERVED6 572 600 G_NO_OF_SATELLITES(co->NumberOfGLONASSSat) 601 if(co->ClockDataSupplied) 602 return GCOBR_DATAMISMATCH; 573 603 co->ClockDataSupplied = 1; 574 604 for(i = CLOCKORBIT_NUMGPS; … … 583 613 break; 584 614 case COTYPE_GLONASSCOMBINED: 585 if(!co) return -5;586 G_GLONASS_EPOCH_TIME(co->GLONASSEpochTime )615 if(!co) return GCOBR_NOCLOCKORBITPARAMETER; 616 G_GLONASS_EPOCH_TIME(co->GLONASSEpochTime, co->NumberOfGLONASSSat) 587 617 G_MULTIPLE_MESSAGE_INDICATOR(mmi) 588 618 G_RESERVED6 589 619 G_NO_OF_SATELLITES(co->NumberOfGLONASSSat) 620 if(co->ClockDataSupplied || co->OrbitDataSupplied) 621 return GCOBR_DATAMISMATCH; 590 622 co->OrbitDataSupplied = 1; 591 623 co->ClockDataSupplied = 1; … … 612 644 break; 613 645 case BTYPE_GPS: 614 if(!b) return -4;615 G_GPS_EPOCH_TIME(b->GPSEpochTime )646 if(!b) return GCOBR_NOBIASPARAMETER; 647 G_GPS_EPOCH_TIME(b->GPSEpochTime, co->NumberOfGPSSat) 616 648 G_MULTIPLE_MESSAGE_INDICATOR(mmi) 617 649 G_RESERVED6 … … 629 661 break; 630 662 case BTYPE_GLONASS: 631 if(!b) return -4;632 G_GPS_EPOCH_TIME(b->GLONASSEpochTime )663 if(!b) return GCOBR_NOBIASPARAMETER; 664 G_GPS_EPOCH_TIME(b->GLONASSEpochTime, co->NumberOfGLONASSSat) 633 665 G_MULTIPLE_MESSAGE_INDICATOR(mmi) 634 666 G_RESERVED6 … … 647 679 break; 648 680 default: 649 return -3; 650 } 651 return mmi ? 1 : 0; 681 return GCOBR_UNKNOWNTYPE; 682 } 683 if(bytesused) 684 *bytesused = sizeofrtcmblock+6; 685 return mmi ? GCOBR_MESSAGEFOLLOWS : GCOBR_OK; 652 686 } 653 687 #endif /* NODECODE */ -
trunk/BNS/RTCM/clock_orbit_rtcm.h
r862 r878 102 102 int moremessagesfollow, char *buffer, size_t size); 103 103 104 /* returns 0 if all ok and < 0 in case of an error, a value of 1 means 105 multiple data flags was found and there probably is at least one more block 106 for same epoch */ 107 /* buffer should point to a RTCM3 block. The functions does not check if the 108 block is valid, but assumes it has already been checked. 109 As a result either co or b are filled with data. 110 NOTE: data is not overwritten, but appended. You get an error if the dataset 111 do not match (i.e. mismatch in time). 112 */ 113 int GetClockOrbitBias(struct ClockOrbit *co, struct Bias *b, 114 const char *buffer, size_t size); 104 enum GCOB_RETURN { 105 /* all well */ 106 GCOBR_MESSAGEFOLLOWS = 1, 107 GCOBR_OK = 0, 108 /* unknown data, a warning */ 109 GCOBR_UNKNOWNTYPE = -1, 110 GCOBR_UNKNOWNDATA = -2, 111 GCOBR_CRCMISMATCH = -3, 112 /* failed to do the work */ 113 GCOBR_NOCLOCKORBITPARAMETER = -10, 114 GCOBR_NOBIASPARAMETER = -11, 115 /* data mismatch - data in storage does not match new data */ 116 GCOBR_TIMEMISMATCH = -20, 117 GCOBR_DATAMISMATCH = -21, 118 /* not enough data - can decode the block completely */ 119 GCOBR_SHORTBUFFER = -30, 120 GCOBR_MISSINGBITS = -31, 121 GCOBR_MESSAGEEXCEEDSBUFFER = -32 122 }; 123 124 /* NOTE: When an error message has been emitted, the output structures may have been modified. Make a copy of the previous variant before calling the 125 function to have a clean state. */ 126 127 /* buffer should point to a RTCM3 block */ 128 enum GCOB_RETURN GetClockOrbitBias(struct ClockOrbit *co, struct Bias *b, 129 const char *buffer, size_t size, int *bytesused); 115 130 116 131 #endif /* RTCM3_CLOCK_ORBIT_RTCM_H */
Note:
See TracChangeset
for help on using the changeset viewer.