beautypg.com

Sapphire pseudocode for coordinate conversions – NavCom Sapphire Rev.J User Manual

Page 395

background image

Sapphire Technical Reference Manual Rev. J

395

}
}
else if( ch is not ascii_char )
{
// Got a 'non-ASCII' character, parse fails
Error handling;
}
else if( crc_count >= 4 )
{
// CRC string is too long
Error handling;
}
else
{
// Save this character on the end of the crc string and
// add null terminator after it.
crc_str[crc_count] = ch;
crc_count++;
crc_str[crc_count] = 0;
}
break;
}// end switch on parse state

// Input character has been processed.
// Check if initial parse has completed or failed.

if( flag PARSE_COMPLETED_OK is set )
{
if(

mnemonic matches “PVT1B” )

{// msg_body holds binary data for PVT1B
Decode msg_body using [PVT1B] format definition
}
}
} // end of LOOP

Sapphire Pseudocode for Coordinate Conversions

This is example source code for properly parsing the LAT|LON|HGHT from the PVT1B
message:

if

( msg.IsNavValid())

{

double

latitude = msg.GetLatitude();

double

longitude = msg.GetLongitude();

double

height = msg.GetHeight();

}

// convert from S32 in arc-seconds scaled to 2^-11
// to R64 as degrees.minutes

R64 CNovaPVT1B::GetLatitude()
{

if

(IsPvtRevision1OrPvtRevision2())

{
R64 xTmp = rev1_latitude;

// convert S32 to R64

xTmp = xTmp / 2048.0;

// convert to arc-seconds

// pull the latitude correction