Manual

PNI Sensor Corporation DOC#1014688 r06
TCM User Manual July 2013 Page 62
7.4.2 CommProtocol.h File
#pr agma once
#i ncl ude " Syst emSer Por t . h"
#i ncl ude " Pr ocesses. h"
//
/ / CommHandl er i s a base cl ass t hat pr ovi des a cal l back f or
//i ncomi ng messages.
//
cl ass CommHandl er
{
publ i c:
/ / Cal l back t o be i mpl ement ed i n der i ved cl ass.
vi r t ual voi d Handl eComm( UI nt 8 f r ameType, voi d * dat aPt r =
NULL, UI nt 16 dat aLen = 0) { }
};
//
/ / CommPr ot ocol handl es t he act ual ser i al communi cat i on wi t h t he / /
modul e.
/ / Pr ocess i s a base cl ass t hat pr ovi des CommPr ot ocol wi t h
// cooper at i ve par al l el pr ocessi ng. The Cont r ol met hod wi l l be
/ / cal l ed by a pr ocess manager on a cont i nuous basi s.
//
cl ass CommPr ot ocol : publ i c Pr ocess
{
publ i c:
enum
{
/ / Fr ame I Ds ( Commands)
kGet ModI nf o / / 1
kGet ModI nf oResp, / / 2
kSet Dat aComponent s, / / 3
kGet Dat a, / / 4
kGet Dat aResp, // 5
/ / Dat a Component I Ds
kHeadi ng = 5, / / 5 - t ype Fl oat 32
kTemper at ur e = 7, / / 7 - t ype Fl oat 32
kAccel X = 21, / / 21 - t ype Fl oat 32
kAccel Y, / / 22 - t ype Fl oat 32
kAccel Z, / / 23 - t ype Fl oat 32
kPi t ch, / / 24 - t ype Fl oat 32
kRol l , / / 25 - t ype Fl oat 32
};
enum
{
kBuf f er Si ze = 512, // max si ze of i nput buf f er
kPacket Mi nSi ze = 5 / / mi n si ze of ser i al packet
};
/ / Ser Por t i s a ser i al communi cat i on obj ect abst r act i ng
// t he har dwar e i mpl ement at i on