KatanaNativeInterface $VERSION$
cdlCOM.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 _CDLCOM_H_
24#define _CDLCOM_H_
25
26#include "common/dllexport.h"
27
28#include "KNI/cdlBase.h"
30
31#include <string>
32
33
34//-------------------------------------------------------//
35#ifdef WIN32
36//-------------------------------------------------------//
37 #include <windows.h>
38//-------------------------------------------------------//
39#else //LINUX
40//-------------------------------------------------------//
41 #include <termios.h>
42 #include <fcntl.h>
43 #include <cerrno>
44//-------------------------------------------------------//
45#endif //WIN32 else LINUX
46//-------------------------------------------------------//
47
48
54 int port;
55 int baud;
56 int data;
57 int parity;
58 int stop;
59 int rttc;
60 int wttc;
61};
62
63//--------------------------------------------------------------------------//
64
65
73class DLLDIR CCdlCOM : public CCdlBase {
74private:
75 std::string _deviceName;
76
77protected:
78
80
81//-------------------------------------------------------//
82#ifdef WIN32
83//-------------------------------------------------------//
84 HANDLE _prtHdl;
85 COMMTIMEOUTS _oto;
86//-------------------------------------------------------//
87#else //LINUX
88//-------------------------------------------------------//
89 int _prtHdl;
90 struct termios _oto;
91//-------------------------------------------------------//
92#endif //WIN32 else LINUX
93//-------------------------------------------------------//
94
95protected:
96
99 static char digit(const int _val) {
100 return (char)((int)'0' + _val);
101 }
102
103public:
110 CCdlCOM(TCdlCOMDesc ccd, const char *dev_name = 0);
111 virtual ~CCdlCOM();
114 virtual int send(const void* buf, int size);
117 virtual int recv(void* buf, int size);
120};
121
122
123#endif //_CDLCOM_H_
124
Abstract base class for devices.
Definition: cdlBase.h:47
virtual int recv(void *_buf, int _sz)=0
Pure function to receive data.
virtual int send(const void *_buf, int _sz)=0
Pure function to send data.
Encapsulates the serial port device.
Definition: cdlCOM.h:73
TCdlCOMDesc _ccd
Stores the attributes of the serial port device.
Definition: cdlCOM.h:79
int _prtHdl
port handle
Definition: cdlCOM.h:89
static char digit(const int _val)
Converts an integer to a char.
Definition: cdlCOM.h:99
CCdlCOM(TCdlCOMDesc ccd, const char *dev_name=0)
Construct a CCdlCOM class.
std::string _deviceName
Definition: cdlCOM.h:75
#define DLLDIR
Definition: dllexport.h:30
This structrue stores the attributes for a serial port device.
Definition: cdlCOM.h:53
int baud
baud rate of port
Definition: cdlCOM.h:55
int wttc
write total timeout
Definition: cdlCOM.h:60
int port
serial port number
Definition: cdlCOM.h:54
int stop
stop bit
Definition: cdlCOM.h:58
int data
data bit
Definition: cdlCOM.h:56
int rttc
read total timeout
Definition: cdlCOM.h:59
int parity
parity bit
Definition: cdlCOM.h:57