Prime.cp file, 5 prime.cp file – PNI CompassPoint Prime User Manual
Page 65
Prime User Manual r08
Page 59
8.5
Prime.cp File
#include "Prime.h"
#include "TickGenerator.h"
const UInt8 kDataCount = 4;// We will be requesting 4 components
//(Heading, pitch, roll, temperature)
//
// This object polls the Prime unit once a second for heading,
// pitch, roll and temperature.
//
Prime::Prime(SerPort * serPort)
: Process("Prime")
{
// Let the CommProtocol know this object will handle any
// serial data returned by the unit
mComm = new CommProtocol(this, serPort);
mTime = 0;
mStep = 1;
}
Prime::~Prime()
{
}
//
// Called by the CommProtocol object when a frame is completely
// received
//
void Prime::HandleComm(UInt8 frameType, void * dataPtr,
UInt16 dataLen)
{
UInt8 * data = (UInt8 *)dataPtr;
switch(frameType)
{
case CommProtocol::kDataResp:
{
// 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)
{