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

📄 gsv.cpp

📁 This is a GPS communication source code to interrupt the NMEA code though serial port. Very good
💻 CPP
字号:
#include "nmea0183.h"
#pragma hdrstop

/*
** Author: Samuel R. Blackburn
** Internet: sam_blackburn@pobox.com
**
** You can use it any way you like as long as you don't try to sell it.
**
** Copyright, 1996, Samuel R. Blackburn
**
** $Workfile: gsv.cpp $
** $Revision: 5 $
** $Modtime: 10/10/98 2:48p $
*/

#ifdef _DEBUG
#undef THIS_FILE
static char BASED_CODE THIS_FILE[] = __FILE__;
#endif

GSV::GSV()
{
   Mnemonic = "GSV";
   Empty();
}

GSV::~GSV()
{
   Mnemonic.Empty();
   Empty();
}

void GSV::Empty( void )
{
  
   NumberOfSatellites = 0;

   int index = 0;

   while( index < 12 )
   {
      SatellitesInView[ index ].Empty();
      index++;
   }
}

BOOL GSV::Parse( const SENTENCE& sentence )
{
   /*
   ** GSV - TRANSIT Position - Latitude/Longitude
   ** Location and time of TRANSIT fix at waypoint
   **
   **        1 2 3  4  5  6   7  8  9  10  11 12 13 14  15 16 17 18  19  20
   **        | | |  |  |  |   |  |  |  |   |  |  |  |   |  |  |  |   |   |
   ** $--GSV,x,x,xx,xx,xx,xxx,xx,xx,xx,xxx,xx,xx,xx,xxx,xx,xx,xx,xxx,xx,*hh<CR><LF>
   **
   **  1) Total number of messages, 1-3
   **  2) Message Number, 1-3
   **  3) Total number of satellites in view
   **  4) Satellite Number #1
   **  5) Elevation #1
   **  6) Azimuth, Degrees True #1
   **  7) SNR #1, NULL when not tracking
   **  8) Satellite Number #2
   **  9) Elevation #2
   ** 10) Azimuth, Degrees True #2
   ** 11) SNR #2, NULL when not tracking
   ** 12) Satellite Number #3
   ** 13) Elevation #3
   ** 14) Azimuth, Degrees True #3
   ** 15) SNR #3, NULL when not tracking
   ** 16) Satellite Number #4
   ** 17) Elevation #4
   ** 18) Azimuth, Degrees True #4
   ** 19) SNR #4, NULL when not tracking
   ** 20) Checksum
   */  

   /*
   ** First we check the checksum...
   */

   if ( sentence.IsChecksumBad( 20 ) == True )
   {
      SetErrorMessage( "Invalid Checksum" );
      return( FALSE );
   }

   int message_number = sentence.Integer( 2 );

   NumberOfSatellites = sentence.Integer( 3 );

   int index = 0;

   while( index < 4 )
   {
      SatellitesInView[ ( ( message_number - 1 ) * 4 ) + index ].Parse( ( index * 4 ) + 4, sentence );
      index++;
   }

   return( TRUE );
}

BOOL GSV::Write( SENTENCE& sentence )
{
   /*
   ** Let the parent do its thing
   */
   
   RESPONSE::Write( sentence );

   /*
   ** OK, this is a hack, I'll figure out how to do multiple messages later
   */

   sentence.Finish();

   return( TRUE );
}

const GSV& GSV::operator = ( const GSV& source )
{
   NumberOfSatellites = source.NumberOfSatellites;

   int index = 0;

   while( index < 12 )
   {
      SatellitesInView[ index ] = source.SatellitesInView[ index ];
      index++;
   }


   return( *this );
}

⌨️ 快捷键说明

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