kmlSctBase.cpp
Go to the documentation of this file.
1 //
2 // C++ Implementation: kmlSctBase
3 //
4 // Description:
5 //
6 //
7 // Author: Tiziano Müller <tiziano.mueller@neuronics.ch>, (C) 2006
8 //
9 // Copyright: See COPYING file that comes with this distribution
10 //
11 //
12 
13 #include "KNI/kmlSctBase.h"
14 
15 
16 bool CSctBase::init(CKatBase* _own, const TSctDesc _sctDesc, CCplBase* _protocol) {
17  gnl.own = _own;
18  gnl.SID = _sctDesc.ctrlID;
19  gnl.res = _sctDesc.sens_res;
20  dat.cnt = _sctDesc.sens_count;
21  dat.arr = new short[dat.cnt];
22  protocol = _protocol;
23  return true;
24 }
25 
26 
28  int i; //iterator
29  byte p[32]; //packet
30  byte buf[256]; //readbuf
31  byte sz = 0; //readbuf size
32 
33  //switch between 8/12 bit resolution
34  p[0] = 'E';
35  p[1] = gnl.SID;
36 
37  protocol->comm(p,buf,&sz);
38  if (!buf[1])
39  throw ParameterReadingException("DAT");
40  for (i=0; i<dat.cnt; i++) {
41  dat.arr[i] = (short)buf[i+2];
42  }
43 
44 }
unsigned char byte
type specification (8 bit)
Definition: cdlBase.h:29
TSctGNL gnl
controller generals
Definition: kmlSctBase.h:77
short sens_count
count of sensors
Definition: kmlSctBase.h:36
Abstract base class for protocol definiton.
Definition: cplBase.h:47
TSctDAT dat
sensor data
Definition: kmlSctBase.h:78
byte ctrlID
controller number (ID)
Definition: kmlSctBase.h:34
Base Katana class.
Definition: kmlBase.h:132
CCplBase * protocol
protocol interface
Definition: kmlSctBase.h:85
short cnt
count of sensors
Definition: kmlSctBase.h:58
short * arr
sensor data
Definition: kmlSctBase.h:59
virtual void comm(const byte *pack, byte *buf, byte *size)=0
Base communication function.
short res
resolution: 8/12 bit
Definition: kmlSctBase.h:52
byte SID
slave ID
Definition: kmlSctBase.h:51
sensor controller description (partly)
Definition: kmlSctBase.h:33
CKatBase * own
parent robot
Definition: kmlSctBase.h:50
short sens_res
resolution: 8/12 bit
Definition: kmlSctBase.h:35
bool init(CKatBase *_own, const TSctDesc _sctDesc, CCplBase *protocol)
Definition: kmlSctBase.cpp:16
void recvDAT()
receive data
Definition: kmlSctBase.cpp:27


kni
Author(s): Martin Günther
autogenerated on Fri Jun 7 2019 22:06:44