COVISE Core
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
SerialCom.h
Go to the documentation of this file.
1 /* This file is part of COVISE.
2 
3  You can use it under the terms of the GNU Lesser General Public License
4  version 2.1 or later, see lgpl-2.1.txt.
5 
6  * License: LGPL 2+ */
7 
8 #ifndef __SERIAL_COM_H_
9 #define __SERIAL_COM_H_
10 // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
11 // CLASS SerialCom
12 //
13 // Initial version: 2003-01-22 [we]
14 // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
15 // (C) 2001 by VirCinity IT Consulting
16 // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
17 // Changes:
18 //
19 #include "common.h"
20 #ifdef WIN32
21 #elif defined(__hpux)
22 #include <termio.h>
23 #else
24 #include <termios.h>
25 #endif
26 
32 namespace covise
33 {
34 
36 {
37 public:
38  // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
39  // ++ Constructors / Destructor
40  // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
41 
45  SerialCom(const char *device, int baudrate, int DataBits = 8, int Parity = 'N', int StopBits = 1);
46 
48  virtual ~SerialCom();
49 
50  // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
51  // ++ Operations
52  // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
53 
55  // return number of read bytes
56  int read(void *data, int bufLen, int max_time = 5);
57 
58  int read(void *data, int bufLen, struct timeval &timeout);
59 
61  // return number of written bytes
62  int write(void *data, int bufLen);
63 
64  // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
65  // ++ Attribute request/set functions
66  // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
67 
68  // return true if an error occurred
69  bool isBad() const;
70 
71  // return error message
72  const char *errorMessage() const;
73 
74 protected:
75  // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
76  // ++ Attributes
77  // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
78 
79  // Error code from errno if something went bad, 0 otherwise
80  char d_error[1024];
81 
82 // file descriptor for serial channel
83 #ifdef _WIN32
84  HANDLE d_channel;
85 #else
86  int d_channel;
87 #endif
88 
89 private:
90  // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
91  // ++ Internally used functions
92  // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
93 
94  // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
95  // ++ prevent auto-generated bit copy routines by default
96  // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
97 
99  SerialCom(const SerialCom &);
100 
102  SerialCom &operator=(const SerialCom &);
103 
105  SerialCom();
106 };
107 }
108 #endif
GLbitfield GLuint64 timeout
Definition: khronos-glext.h:7882
Definition: SerialCom.h:35
int d_channel
Definition: SerialCom.h:86
GLsizei GLsizei GLenum GLenum const GLvoid * data
Definition: khronos-glext.h:6354
#define UTILEXPORT
Definition: coExport.h:182