41 cmd[(int)
'B'].send_sz = 1;
42 cmd[(int)
'B'].read_sz = 3;
43 cmd[(int)
'X'].send_sz = 1;
44 cmd[(int)
'X'].read_sz = 181;
45 cmd[(int)
'Y'].send_sz = 1;
46 cmd[(int)
'Y'].read_sz = 84;
47 cmd[(int)
'Z'].send_sz = 1;
48 cmd[(int)
'Z'].read_sz = 1;
49 cmd[(int)
'C'].send_sz = 5;
50 cmd[(int)
'C'].read_sz = 3;
51 cmd[(int)
'D'].send_sz = 2;
52 cmd[(int)
'D'].read_sz = 8;
53 cmd[(int)
'E'].send_sz = 2;
54 cmd[(int)
'E'].read_sz = 18;
55 cmd[(int)
'V'].send_sz = 3;
56 cmd[(int)
'V'].read_sz = 13;
57 cmd[(int)
'N'].send_sz = 3;
58 cmd[(int)
'N'].read_sz = 13;
59 cmd[(int)
'G'].send_sz = 14;
60 cmd[(int)
'G'].read_sz = 2;
61 cmd[(int)
'G'+128].send_sz = 3;
62 cmd[(int)
'G'+128].read_sz = 2;
63 cmd[(int)
'H'].send_sz = 75;
64 cmd[(int)
'H'].read_sz = 3;
65 cmd[(int)
'A'].send_sz = 3;
66 cmd[(int)
'A'].read_sz = 2;
67 cmd[(int)
'S'].send_sz = 6;
68 cmd[(int)
'S'].read_sz = 6;
69 cmd[(int)
'I'].send_sz = 2;
70 cmd[(int)
'I'].read_sz = 3;
71 cmd[(int)
'M'].send_sz = 5;
72 cmd[(int)
'M'].read_sz = 4;
73 cmd[(int)
'T'].send_sz = 5;
74 cmd[(int)
'T'].read_sz = 2;
108 short tries_recv = 0;
197 bool getErrorMessage =
false;
200 std::cout <<
"Error flag received:\n";
202 getErrorMessage =
true;
205 if (*size != read_sz) {
211 byte bhi = read_buf[read_sz-2];
212 byte blo = read_buf[read_sz-1];
218 if ((hi != bhi) || (lo != blo)) {
219 std::cout <<
"warning: crc error, throwing exception" << std::endl;
223 if (getErrorMessage) {
231 byte size_errormsg = 57;
232 recv(buf, 57, &size_errormsg);
234 std::cout <<
"Error while requesting error message!\n";
238 std::cout <<
"bad response to error request\n";
240 byte lastCommand = buf[1];
241 byte errorCode = buf[2];
243 std::string errorString((
char*)buf+4);
245 errorString +=
" (axis ";
246 errorString +=
'0' +
device;
250 throw FirmwareException(errorString, static_cast<signed char>(errorCode), device, lastCommand);
virtual int recv(void *_buf, int _sz)=0
Pure function to receive data.
unsigned char byte
type specification (8 bit)
byte send_sz
send size of the packet
virtual void getMasterFirmware(short *fw, short *rev)
Get the master firmware of the robot we are communicating with.
#define NUMBER_OF_RETRIES_SEND
virtual int send(const void *_buf, int _sz)=0
Pure function to send data.
TPacket cmd[256]
command table
virtual bool init(CCdlBase *_device, byte _kataddr=24)
Initializing function.
Exception reported by the firmware.
uint16 CRC_CHECKSUM(uint8 *data, uint8 size_of_BYTE)
#define uint8
unsigned 8 bit
CRC check for the answer package failed.
virtual void defineProtocol(byte _kataddr)
Defines the protocol's attributes.
byte send_buf[256]
sending buffer
const int KATANA_ERROR_FLAG
defines the error flag number
virtual void recv(byte *read_buf, byte read_sz, byte *size)
virtual void comm(const byte *pack, byte *buf, byte *size)
Communication function.
#define NUMBER_OF_RETRIES_RECV
byte read_sz
read size of the packet
short mMasterVersion
master version of robot we are communicating with
virtual bool load_tbl()
Loads the command table from the robot's firmware.
virtual void send(byte *send_buf, byte write_sz, short retries=3)
CCdlBase * device
communication device
byte read_buf[256]
receive buffer
Abstract base class for devices.
short mMasterRevision
master firmware revision