Seatrax.cpp file, 5 seatrax.cpp file – PNI SeaTRAX User Manual

Page 73

Advertising
background image

PNI Sensor Corporation

DOC#1018154 r02

SeaTRAX User Manual

Page 68

7.4.5

SeaTRAX.cpp File


#include "SeaTRAX.h"
#include "TickGenerator.h"

const UInt8 kDataCount = 4;

// We will be requesting 4 components (heading, pitch, roll, and
// temperature)
//
// This object polls the SeaTRAX module once a second for
// heading, pitch, roll and temperature.
//

SeaTRAX:: SeaTRAX(SerPort * serPort)
: Process("SeaTRAX")
{
// Let the CommProtocol know this object will handle any
// serial data returned by the module

mComm = new CommProtocol(this, serPort);

mTime = 0;

mStep = 1;

}

SeaTRAX::~ SeaTRAX()
{
}

//
// Called by the CommProtocol object when a frame is completely //
received
//
void SeaTRAX::HandleComm(UInt8 frameType, void * dataPtr, UInt16
dataLen)
{

UInt8 * data = (UInt8 *)dataPtr;


switch(frameType)

{

case CommProtocol::kGetDataResp:

{

// Parse the data response

UInt8 count = data[0];

// The number of data elements returned

UInt32 pntr = 1;

// Used to retrieve the returned elements

// The data elements we requested

Float32 heading, pitch, roll, temperature;

if(count != kDataCount)

{

Advertising