⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gpsrcvr.bak

📁 OpenSource GPS is software for x86 PCs that allows you to acquire, track and demodulate signals from
💻 BAK
📖 第 1 页 / 共 3 页
字号:
/***********************************************************************
  GPS RECEIVER (GPSRCVR) Ver. 1.18

  12 Channel All-in-View GPS Receiver Program based on Mitel GP2021
  chipset

  This program is licensed under BSD LICENSE
  This LICENSE file must be included with the GPSRCVR code.

  Copyright (c) 2005, Clifford Kelley <cwkelley@earthlink.net>
  All rights reserved.


  Redistribution and use in source and binary forms, with or without 
  modification, are permitted provided that the following conditions
  are met:

  1. Redistributions of source code must retain the above copyright notice,
  this list of conditions and the following disclaimer.

  2. Redistributions in binary form must reproduce the above copyright notice,
  this list of conditions and the following disclaimer in the documentation
  and/or other materials provided with the distribution.
 
  3. Neither the name of the author nor the names of its contributors
  may be used to endorse or promote products derived from this software 
  without specific prior written permission.
 
  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 
  TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 
  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 
  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 
  OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 
  OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


  I would like to thank the following people who have contributed to
  OpenSource GPS.  If I have left someone out I appologize and ask you
  to correct my oversight.

  Joel Barnes        University of New South Wales, Australia
  Jingrong Cheng     University of California Riverside
  Georg Beyerle      GFZ, Germany
  Alberto Perez
  Phil Bender
  Doug Baker
  Elmer Thomas       University of California Riverside
  Andrew Greenberg   Portland State University
  Takuji Ebinuma
  Serguei Miridonov
  Goetz Kappen


Revisions
  1.18  Fixed an error in the data bit test in GPSISR. Thanks Andrew! Added a
  simple 8 state Kalman filter, unfortunately it only works under MS VC++ 1.5
  since it uses Alberto Perez's matrix routines and Borland does not seem to
  like them.

  1.17a Released under the BSD license

  1.17  Added data bit recording and write to file (this feature is not completely
  debugged), corrected error in satpos_almanac, Thanks Tak! Also corrected an
  error in navmess, thanks Goetz!  Also added an indication on page 1 which
  interface (ISA or PCI) is being used and the almanac page number.
  
  1.16
  Addes #ifdefs to allow compilation by DJGPP.  Setup use of PCI interface
  Modified almanac read logic to check when a new almanac is available

  1.15
  Added more integrity checking into the data bit synchronization in the pull-in
  state.  Instead of just checking the change in phase and checking that it is
  very close to a +-90 to -+90 transition it also stores the last 20 ms sign
  values and they must all be the same and opposite of the transitioned ms sign
  before declaring the edge of a data bit.  Modified parity check algorithm to
  be more efficient. Also made constants for number of channels and register
  address and data address.
  1.14
  Fixed error in nmea checksum routine.  Added another display page and
  supporting data structure to show parity errors in navigation message
  decoding.
  1.13
  Made mods to get ICP working better, trying to use just the last 0.1 second
  of carrier phase data.  Phil Bender added NMEA serial port messages (needs
  some more work, see files serport.cpp, nmea.cpp, fwinter.cpp). Additional
  entries at the bottom of rcvr_par.dat are used to set up the NMEA messages.
  Adapted program so it can compile under Borland (#ifdef BCPP) or Microsoft
  Visual CPP (#ifdef VCPP)  Also split up the program into library components
  to make it more modular (see GPS_ISR.CPP and NAVFIX.CPP)
  1.12
  Removed some of the ephemeris checks that were causing the rejection of
  valid ephemeris messages and also caused it not to accept ephemeris
  messages from a constellation simulator.  Fixed up the 1 second data bit
  ambiguities to recover measurements that previously had been thrown out.
  1.11
  Cleaned up the display when a satellite is removed from consideration
  Fixed an ephemeris management problem that caused occasional use of the
  ephemeris from the wrong satellite
  Modified the ephemeris mgmt to check IODE and IODC to decide when
  to grab a new ephemeris + ephemeris integrity checks
  Improved the almanac page redundancy check
  Moved Pr, dPR, Tropo and Iono into the main channel data structure
  Set up default iono parameters when ion_utc.dat not available
  Added a debug output that provides raw measurements data and ephemeris
  which provides more processing capability than pseudorange & delta pseudorange
  Fully implemented the GPSRCVR.LOG output options
  Added the option in RCVR_PAR.DAT to use CTL (carrier tracking loop) or
  ICP (integrated carrier phase) data for velocity computations (ICP seems
  to have bias problems)
  1.10
  Made the read of rcvr_par not so picky as long as the text field has no spaces
  Fixed a problem in CMatrix with the Borland 5.02 compiler
  Re-aligned column titles for pages 2-4
  1.09
  Corrected hot start problem
  Hooked up almanac data type check
  Started using Aberto's matrix libraries for DOP calculations
  Minor changes in pream
  Got rid of tmax in nav_fix
  Added more mesaurement integrity checks in nav_fix
  Added header and tdop to display
  1.08
  Corrected tracking loop bias problem (I hope!)
  Corrected code loop doppler correction constant
  1.07
  Added check for bit sync in pull-in, must be set to transition to track
  Extended pull-in to end of data bit to reduce transients when going into track
  Added integrated carrier phase processing for velocity
  Improved GPS time alignment mode (for any nav fix rate)
  Corrected iono correction computations (again)
  Corrected tropo correction sign
  Reduced debug arrays to reduce code size
  Added two new display pages, iono & tropo, and pseudorange and delta
  pseudorange
  Not used yet but getting set up to use Alberto Perez's matrix libraries
  1.06
  Added new format for Kalman.dat
  corrected iono correction computations
  Added more comments
  1.05
  Improved Code tracking loop
  Added GPS time alignment mode
  Added time zone input from rcvr_par.dat
  Corrected errors in satpos_ephemeris
  Corrected current.eph file format
  1.04
  Corrections in Gpsfuncs
  Added new display page for nav message HOW and TOW
  1.03
  New preamble routine
  Added Carrier phase aiding


***********************************************************************/
#ifdef DJGPP

#include <go32.h>
#include <dpmi.h>

#endif


#ifdef VCPP

#include "graph.h"  // PGB MS

#endif

#ifdef BCPP
extern unsigned _stklen = 64000;
#endif

#include  "serport.h" // NMEA
#include  "NMEA.h"     // NMEA
#include  <time.h>
#include  <stdio.h>
#include  <stdlib.h>
#include  <conio.h>
#include  <math.h>
#include  <string.h>
#include  <io.h>
#include  <Dos.h>


#include "gp2021.h"
#define MAIN
#include  "consts.h"
#include  "structs.h"

#include  "globals.h"
#undef  MAIN

#ifdef VCPP
#include  "CMatrix3.h"           // Matrix function libraries from
#endif                           // Alberto Perez,  Thanks Alberto!!
										   // They will help make the transition
                    			   // to a Kalman filter much easier

#include "gpsfuncs.h"
#include "gpsrcvr.h"
#include "pcifind.c"


/*******************************************************************************
FUNCTION main()
RETURNS  None.

PARAMETERS None.

PURPOSE
	This is the main program to control the GPS receiver

WRITTEN BY
	Clifford Kelley

*******************************************************************************/


unsigned long last_tow;


int main()
{
  char  ch;
  unsigned int ioport;
  int i,sync_set;
  last_tow=1000000;

#ifdef BCPP
     clrscr();
     sprintf(KFtxt,"  ");
#endif

  ioport=pcifind();
  if (ioport == 0)
  {
    Register_address=0x304;            //assume we have an ISA interface
    Data_address=0x308;
    sprintf(IOtxt,"ISA");
  }
  else
  {
    Register_address=(ioport & 0xfff0) + 4;  // we have a PCI interface
    Data_address=(ioport & 0xfff0) +8;
    sprintf(IOtxt,"PCI");
  }

  self_test();
  io_config(0x301);
  test_control(0);
  system_setup(0);
  reset_cntl(0x0);
//  delay(100);
  reset_cntl(0x1fff);
  ch_status=1;
  read_rcvr_par();
  init=1;
  rec_pos_xyz.x=0.0;
  rec_pos_xyz.y=0.0;
  rec_pos_xyz.z=0.0;

  if (out_kalman==1) kalm   =fopen("gpskalm.log","w+");
  if (out_pos==1 || out_vel==1 ||out_time==1) stream=fopen("gpsrcvr.log","w+");
  if (out_debug==1) debug=fopen("debug.log","w+");
  if (out_data==1) data_bits=fopen("navdata.log","w+");
  read_initial_data();
  current_loc=receiver_loc();
  rec_pos_llh.lon=current_loc.lon;
  rec_pos_llh.lat=current_loc.lat;
  rec_pos_llh.hae=current_loc.hae;
  nav_tic=nav_up*10;
  old_TIC_cntr=TIC_cntr=TIC_ref;
//  program_TIC(TIC_cntr);
  code_corr=clock_offset*24.0;
  for (ch=0;ch<N_channels;ch++)
  {
    chan[ch].state=off;
    for (i=0;i<5;i++)chan[ch].word_error[i]=0;
  }
  time(&thetime);  // set up thetime so it can be taken over by this program  
  
#ifdef VCPP
  
  _setbkcolor(1);
  _displaycursor( _GCURSOROFF);
  _clearscreen( _GCLEARSCREEN);  // PGB MS
	
  
	//
	// Get the currnet system time.  MS_TIME
	//
	struct _dostime_t gDosTime;
    struct _dosdate_t gDosDate;
	_dos_gettime( &gDosTime );
	_dos_getdate( &gDosDate );
    sprintf(KFtxt,"KF");

#endif

  if ( status != cold_start ) chan_allocate();
  else if (status==cold_start ) cold_allocate();
  m_time[1]=clock_tow;
  read_ephemeris();
  int err;
#ifndef DJGPP
  open_com( 0, Com0Baud, 0, 1, 8, &err ); // NMEA
#endif

  Interrupt_Install();
//
  do
  {
    if (kbhit()) key = getch();
    else         key = '\0';
	 for (ch=0;ch<=11;ch++)
    {
		if (chan[ch].frame_ready==1 )
      {
	     navmess(chan[ch].prn,ch);   // decode the navigation message
	     chan[ch].frame_ready=0;     // for this channel
      }
    }
    if (sec_flag==1)
    {
#ifndef DJGPP
		SendNMEA();
#endif
//	gotoxy(1,24);
//	printf("->start display");
	  thetime++;

#ifdef BCPP
	  stime(&thetime);
#endif
			
	  clock_tow=(++clock_tow)%604800L;
	  time_on++;
	  sec_flag=0;
	  for (ch=0;ch<N_channels;ch++)
	  {
		  if (chan[ch].state==track)
		  {
	//  Estimate  C/No
           if (chan[ch].avg>0 )
           {
			  chan[ch].CNo=10.*log10(chan[ch].avg/1395.*

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -