KatanaNativeInterface
$VERSION$
Main Page
Modules
Namespaces
Classes
Files
File List
File Members
include
KNI
cplSerial.h
Go to the documentation of this file.
1
/*
2
* Katana Native Interface - A C++ interface to the robot arm Katana.
3
* Copyright (C) 2005 Neuronics AG
4
* Check out the AUTHORS file for detailed contact information.
5
*
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2 of the License, or
9
* (at your option) any later version.
10
*
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
15
*
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
*/
20
21
22
/******************************************************************************************************************/
23
#ifndef _CPLSERIAL_H_
24
#define _CPLSERIAL_H_
25
/******************************************************************************************************************/
26
#include "
common/dllexport.h
"
27
#include "
common/exception.h
"
28
#include "
KNI/cplBase.h
"
29
#include "
KNI/cdlCOMExceptions.h
"
30
31
#define NUMBER_OF_RETRIES_SEND 3 // Number of retries after a failing in the Communication
32
#define NUMBER_OF_RETRIES_RECV 3 // Number of retries after a failing in the Communication
33
/******************************************************************************************************************/
34
36
const
int
KATANA_ERROR_FLAG
= 192;
41
44
class
WrongCRCException
:
public
Exception
{
45
public
:
46
WrongCRCException
() throw ():
47
Exception
("CRC check failed", -20) {}
48
};
49
52
class
FirmwareException
:
public
Exception
{
53
protected
:
54
int
_axis_number
;
55
char
_command_char
;
56
public
:
57
FirmwareException
(
const
std::string & error,
const
int
error_number
,
const
int
axis,
const
char
command)
throw
():
58
Exception
(
"FirmwareException : '"
+ error +
"'"
,
error_number
),
59
_axis_number
(axis),
60
_command_char
(command) {}
61
const
int
axis_number
()
const
throw() {
62
return
_axis_number
;
63
}
64
const
char
command_char
()
const
throw() {
65
return
_command_char
;
66
}
67
};
68
72
75
struct
THeader
{
76
byte
size
;
77
byte
data
[256];
78
};
79
82
struct
TPacket
{
83
byte
send_sz
;
84
byte
read_sz
;
85
};
86
87
//----------------------------------------------------------------------------------------------------------------//
88
89
92
class
DLLDIR
CCplSerial
:
public
CCplBase
{
93
94
protected
:
95
THeader
hdr
;
96
TPacket
cmd[256];
97
98
byte
send_buf[256];
99
byte
read_buf[256];
100
101
protected
:
102
virtual
bool
load_tbl() = 0;
103
virtual
void
defineProtocol(
byte
_kataddr) = 0;
104
};
105
106
//----------------------------------------------------------------------------------------------------------------//
107
112
// class DLLDIR CCplSerialZero : public CCplSerial {
113
//
114
// protected:
115
// virtual bool load_tbl(); //!< Loads the command table from the robot's firmware.
116
// virtual void defineProtocol(byte _kataddr); //!< Defines the protocol's attributes.
117
//
118
// public:
119
// /*! \brief Initializing function
120
// *
121
// * Init the protocols basic attributes.
122
// */
123
// virtual bool init(CCdlBase* _device, byte _kataddr = 24);
124
//
125
//
126
// /*! \brief Communication function
127
// *
128
// * Sends a communications packet and receives one from the robot.
129
// */
130
// virtual TRetCOMM comm(const byte* _pack, byte* _buf, byte* _size);
131
// };
132
133
//----------------------------------------------------------------------------------------------------------------//
134
137
class
DLLDIR
CCplSerialCRC
:
public
CCplSerial
{
138
139
protected
:
140
virtual
bool
load_tbl
();
141
virtual
void
defineProtocol
(
byte
_kataddr);
142
virtual
void
send(
byte
* send_buf,
byte
write_sz,
short
retries = 3);
// Sends a packet.
143
virtual
void
recv(
byte
* read_buf,
byte
read_sz,
byte
* size);
// Receives the packet and checks the CRC.
144
145
public
:
150
virtual
bool
init
(
CCdlBase
* _device,
byte
_kataddr = 24);
151
156
virtual
void
comm
(
const
byte
* pack,
byte
* buf,
byte
* size);
157
162
virtual
void
getMasterFirmware
(
short
* fw,
short
* rev);
163
164
};
165
166
/******************************************************************************************************************/
167
#endif //_CPLSERIALZERO_H_
168
/******************************************************************************************************************/
Generated by
1.8.4