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"
29 #include "KNI/cdlCOMExceptions.h"
30 
31 //<tfromm date="22.05.2009">
32 //#include <string>
33 #include <cstring>
34 //</tfromm>
35 
36 //-------------------------------------------------------//
37 #ifdef WIN32
38 //-------------------------------------------------------//
39  #include <windows.h>
40 //-------------------------------------------------------//
41 #else //LINUX
42 //-------------------------------------------------------//
43  #include <termios.h>
44  #include <fcntl.h>
45  #include <cerrno>
46 //-------------------------------------------------------//
47 #endif //WIN32 else LINUX
48 //-------------------------------------------------------//
49 
50 
55 struct TCdlCOMDesc {
56  int port;
57  int baud;
58  int data;
59  int parity;
60  int stop;
61  int rttc;
62  int wttc;
63 };
64 
65 //--------------------------------------------------------------------------//
66 
67 
75 class DLLDIR CCdlCOM : public CCdlBase {
76 private:
77  std::string _deviceName;
78 
79 protected:
80 
82 
83 //-------------------------------------------------------//
84 #ifdef WIN32
85 //-------------------------------------------------------//
86  HANDLE _prtHdl;
87  COMMTIMEOUTS _oto;
88 //-------------------------------------------------------//
89 #else //LINUX
90 //-------------------------------------------------------//
91  int _prtHdl;
92  struct termios _oto;
93 //-------------------------------------------------------//
94 #endif //WIN32 else LINUX
95 //-------------------------------------------------------//
96 
97 protected:
98 
101  static char digit(const int _val) {
102  return (char)((int)'0' + _val);
103  }
104 
105 public:
112  CCdlCOM(TCdlCOMDesc ccd);
113  virtual ~CCdlCOM();
116  virtual int send(const void* buf, int size);
119  virtual int recv(void* buf, int size);
122 };
123 
124 
125 #endif //_CDLCOM_H_
126 
static char digit(const int _val)
Converts an integer to a char.
Definition: cdlCOM.h:101
int data
data bit
Definition: cdlCOM.h:58
int stop
stop bit
Definition: cdlCOM.h:60
#define DLLDIR
Definition: dllexport.h:30
std::string _deviceName
Definition: cdlCOM.h:77
int wttc
write total timeout
Definition: cdlCOM.h:62
int baud
baud rate of port
Definition: cdlCOM.h:57
#define HANDLE
Definition: pthread.h:297
int port
serial port number
Definition: cdlCOM.h:56
This structrue stores the attributes for a serial port device.
Definition: cdlCOM.h:55
TCdlCOMDesc _ccd
Stores the attributes of the serial port device.
Definition: cdlCOM.h:81
int _prtHdl
port handle
Definition: cdlCOM.h:91
Encapsulates the serial port device.
Definition: cdlCOM.h:75
int rttc
read total timeout
Definition: cdlCOM.h:61
byte size
Definition: kni_wrapper.cpp:35
Abstract base class for devices.
Definition: cdlBase.h:47
int parity
parity bit
Definition: cdlCOM.h:59


kni
Author(s): Martin Günther
autogenerated on Fri Jan 3 2020 04:01:16