HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
UT_Serial.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: UT_Serial.h ( Channel Operator Library, C++)
7  *
8  * COMMENTS:
9  *
10  * Implements an interface to the serial port interface.
11  *
12  */
13 #ifndef UT_SERIAL_H
14 #define UT_SERIAL_H
15 
16 #include "UT_API.h"
17 #ifdef WIN32
18 #include <windows.h>
19 #include <winbase.h>
20 #else
21 #define _OLD_TERMIOS
22 #include <termios.h>
23 #endif
24 
25 #define SERIAL_NO_PARITY 0
26 #define SERIAL_ODD_PARITY 1
27 #define SERIAL_EVEN_PARITY 2
28 
30 {
31 public:
32  explicit UT_Serial(int rate = 9600,
33  int databits = 8,
34  int parity = SERIAL_NO_PARITY,
35  int stopbits = 1);
36 
37  virtual ~UT_Serial();
38 
39  int open(const char *port, int parms);
40  void close();
41 
42  int changeRate(int rate);
43 
44  int dataAvailable();
45  int read(void *buffer, int num);
46  int write(const void *buffer, int num);
47 
48  void flush();
49 
50 private:
51  int mySpeed;
52  int myDataBits;
53  int myStopBits;
54  int myParity;
55 
56  // platform specific
57 #ifdef WIN32
58  HANDLE myFD;
59  COMMCONFIG myPreviousState;
60  COMMCONFIG mySerialState;
61  int mySerialStateSaved;
62  int myDataAvailable;
63  char myStoredChar;
64 #else
65  int myFD;
66  struct termios myPreviousState;
67  struct termios mySerialState;
68 #endif
69 };
70 
71 #endif
#define UT_API
Definition: UT_API.h:12
void read(T &in, bool &v)
Definition: ImfXdr.h:611
GLuint buffer
Definition: glcorearb.h:659
#define SERIAL_NO_PARITY
Definition: UT_Serial.h:25
virtual int open(float queuesize)
virtual void close()
png_infop png_uint_32 int num
Definition: png.h:2158
void write(T &out, bool v)
Definition: ImfXdr.h:332