PNI TCM 5 User Manual
Page 59
PNI Sensor Corporation
Doc #1007537 r12
TCM3 & TCM5 User Manual
– Sept 2012
Page 59
//
// Have the CommProtocol build and send the frame to the unit.
//
void
TCM::SendComm(UInt8 frameType,
void
* dataPtr, UInt16 dataLen)
{
if
(mComm) mComm->SendData(frameType, dataPtr, dataLen);
// Ticks is a timer function. 1 tick = 10msec.
mResponseTime = Ticks() +
300
;
// Expect a response within 3 seconds
}
//
// This is called each time this process gets a turn to execute.
//
void
TCM::Control()
{
switch
(mStep)
{
case
1
:
{
UInt8 pkt[kDataCount +
1
];
// the compents we are requesting, preceded by the
number of...
// ...components being requested
pkt[
0
] = kDataCount;
pkt[
1
] = CommProtocol::kHeading;
pkt[
2
] = CommProtocol::kPAngle;
pkt[
3
] = CommProtocol::kRAngle;
pkt[
4
] = CommProtocol::kTemperature;
SendComm(CommProtocol::kSetDataComponents, pkt, kDataCount +
1
);
// Ticks is a timer function. 1 tick = 10msec.
mTime = Ticks() +
100
;
// Taking a sample in 1s.
mStep++;
// go to next step of process
break
;
}
case
2
:
{
// Ticks is a timer function. 1 tick = 10msec.
if
(Ticks() > mTime)
{
// tell the unit to take a sample
SendComm(CommProtocol::kGetData);
mTime = Ticks() +
100
;
// take a sample every second
mStep++;
}