beautypg.com

NavCom Sapphire Rev.J User Manual

Page 182

background image

Sapphire Technical Reference Manual Rev. J

182

int

I = 0;

int

lenidx = 0;

CorrectionsByteArray[i++] = (

byte

)

’[‘

;

CorrectionsByteArray[i++] = (

byte

)

’P’

;

CorrectionsByteArray[i++] = (

byte

)

’A’

;

CorrectionsByteArray[i++] = (

byte

)

’C’

;

CorrectionsByteArray[i++] = (

byte

)

’K’

;

CorrectionsByteArray[i++] = (

byte

)

’B’

;

CorrectionsByteArray[i++] = (

byte

)

’]’

;


lenidx = I;

CorrectionsByteArray[i++] = (

byte

)Length;

CorrectionsByteArray[i++] = (

byte

)(Length >> 8);


//CorrectionsByteArray[i++] = (byte)GPSWeek;

//CorrectionsByteArray[i++] = (byte)(GPSWeek >> 8);

// TFS 17877

Uint16

shadowLength = (

Uint16

)~Length;

CorrectionsByteArray[i++] = (

byte

)(shadowLength);

CorrectionsByteArray[i++] = (

byte

)(shadowLength >> 8);


CorrectionsByteArray[i++] = (

byte

)GPSTime;

CorrectionsByteArray[i++] = (

byte

)(GPSTime >> 8);

CorrectionsByteArray[i++] = (

byte

)(GPSTime >> 16);

CorrectionsByteArray[i++] = (

byte

)(GPSTime >> 24);

CorrectionsByteArray[i++] = TimeVersion;

CorrectionsByteArray[i++] = 0;

// corrections type

(0=unk,1=nct,2=rtcm2.3,3=rtcm3.0,4=cmr/cmr+

CorrectionsByteArray[i++] = 0;

// logical port


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

* XOR ALL correction data with 0x55.

* If we send correction data without encoding it parsers on the receiver
may get confused.

* So on sender side we encode it with 0x55 and on receiver side we will
decode it with the

* same value

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

for

(

int

ix = 0; ix < len; ++ix)

{
data[ix] ^= 0x55;
}

Buffer

.BlockCopy(data,0,CorrectionsByteArray,I,len);


// tricky! Short cut way to convert 0xABCD to “ABCD”

Uint32

crc = crc_CCITT(lenidx, Length, CorrectionsByteArray);

string

crcBytes12 = ConvertByteToString((

byte

)((crc >> 8) & 0x0FF));

string

crcBytes34 = ConvertByteToString((

byte

)(crc & 0x0FF));


CorrectionsByteArray[len + i++] = (

byte

)(

‘*’

);

CorrectionsByteArray[len + i++] = (

byte

)crcBytes12[0];

CorrectionsByteArray[len + i++] = (

byte

)crcBytes12[1];

CorrectionsByteArray[len + i++] = (

byte

)crcBytes34[0];

CorrectionsByteArray[len + i++] = (

byte

)crcBytes34[1];

CorrectionsByteArray[len + i++] = (

byte

)(0x0D);

// CR/LF

CorrectionsByteArray[len + i++] = (

byte

)(0x0A);


if

(serialPortOctagon.IsOpen)