beautypg.com

PNI TCM User Manual

Page 76

background image

PNI Sensor Corporation

DOC#1014688 r06

TCM User Manual

– July 2013

Page 71


def aul t :

/ / Mes sage i s a f unc t i on t hat di s pl ay s a f or mat t ed s t r i ng

/ / ( si mi l ar t o pr i nt f )

Mess age( " Unk nown t ype: %02X\ r \ n" ,

dat a[ pnt r - 1] ) ;

/ / unk nown dat a t y pe, s o si ze i s unknown, so s ki p ev er yt hi ng

r et ur n;

br eak;

}

c ount - - ;

/ / One l es s el ement t o r ead i n

}

/ / Mes sage i s a f unc t i on t hat di s pl ay s a f or mat t ed s t r i ng

/ / ( si mi l ar t o pr i nt f )

Mess age( " Headi ng: %f , Pi t ch: %f , Rol l : %f ,

Temper at ur e: %f \ r \ n" , headi ng, pi t c h, r ol l ,

t emper at ur e) ;

mSt ep- - ;

/ / s end next dat a r equest

br eak;

}


def aul t :

{

/ / Mes sage i s a f unc t i on t hat di s pl ay s a f or mat t ed s t r i ng

/ / ( si mi l ar t o pr i nt f )

Mess age( " Unk nown f r ame %02X r ec ei ved\ r \ n" ,

( UI nt 16) f r ameType) ;

br eak;

}

}

}

/ /
/ / Hav e t he CommPr ot ocol bui l d and send t he f r ame t o t he modul e.
/ /
v oi d TCM: : SendComm( UI nt 8 f r ameType, v oi d * dat aPt r , UI nt 16 dat aLen)
{

i f ( mComm) mComm- >SendDat a( f r ameTy pe, dat aPt r , dat aLen) ;

/ / Ti c ks i s a t i mer f unct i on. 1 t i ck = 10ms ec .

mRes pons eTi me = Ti ck s ( ) + 300;

/ / Expec t a r esponse

wi t hi n 3 s ec onds
}
/ /
/ / Thi s i s cal l ed each t i me t hi s pr oces s get s a t ur n t o ex ec ut e.
/ /
v oi d TCM: : Cont r ol ( )
{

s wi t ch( mSt ep)

{

c ase 1:

{

UI nt 8 pk t [ kDat aCount + 1] ;

/ / t he c ompent s we ar e r eques t i ng, pr ec eded by t he number of
/ / c omponent s bei ng r equest ed

pk t [ 0] = k Dat aCount ;

pk t [ 1] = CommPr ot ocol : : kHeadi ng;