COVISE Core
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
32namespace covise
33{
34
36{
37public:
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
74protected:
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
87#endif
88
89private:
90 // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
91 // ++ Internally used functions
92 // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
93
94 // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
95 // ++ prevent auto-generated bit copy routines by default
96 // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
97
100
103
106};
107}
108#endif
#define UTILEXPORT
Definition: coExport.h:206
GLbitfield GLuint64 timeout
Definition: khronos-glext.h:7882
GLsizei GLsizei GLenum GLenum const GLvoid * data
Definition: khronos-glext.h:6354
list of all chemical elements
Definition: coConfig.h:27
Definition: SerialCom.h:36
SerialCom()
Default constructor: NOT IMPLEMENTED, checked by assert.
SerialCom(const SerialCom &)
Copy-Constructor: NOT IMPLEMENTED, checked by assert.
SerialCom & operator=(const SerialCom &)
Assignment operator: NOT IMPLEMENTED, checked by assert.
int d_channel
Definition: SerialCom.h:86