vrecko
virtual reality framework
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
classes.h
Go to the documentation of this file.
1 /***************************************************
2  * - - - - - - - IMMERSION CORP. - - - - - - - *
3  * *
4  * IBM PC/Compatibles software series *
5  * Copyright (c) 1993 *
6  ***************************************************
7  * DRIVE.H | SDK1-2 | November 1995
8  *
9  * Immersion Corp. Software Developer's Kit
10  * Definitions and prototypes for serial communications functions
11  * for the Immersion Corp. MicroScribe-3D
12  * Not for use with the Probe or Personal Digitizer
13  * Requires HCI firmware version MSCR1-1C or later
14  */
15 
16 #ifndef F__CLASSES_H
17 #define F__CLASSES_H
18 
19 #define BAUD 38400
20 #ifdef WIN32
21 #define BAUDCODE CBR_38400
22 #else
23 #define BAUDCODE B38400
24 #endif //WIN32
25 
26 #ifdef _DEBUG
27 #define DEBUG
28 #endif
29 
30 #ifdef DEBUG
31 #define dbg(what) puts(what);
32 #define dbgdf(what) printf("--%d\n", what);
33 #define dbgsf(what) printf("--%s\n", what);
34 #else
35 #define dbg(what)
36 #define dbgdf(what)
37 #define dbgsf(what)
38 #endif
39 
40 
41 
42 #ifdef WIN32
43 #include <windows.h>
44 #else // else
45 #include <termio.h>
46 #endif
47 
48 /* Public constants */
49 #define MIN_TIMEOUT 100
50 #define FRAME_BUF_SIZE 240
51 
52 
53 
54 
55 /* Use hci_result as if it were an enumerated type. Compare variables of
56  * this type to the string constants declared below. An hci_result is
57  * actually a string, so it can be directly printed as well.
58  */
59 typedef char* hci_result;
61 
62 /* Shorthand for a byte */
63 typedef unsigned char byte;
64 
65 /* Timing functions */
66 class Timing
67 {
68  private:
69  long int timeout;
70  unsigned long int stop;
71 
72  public:
73  void pause(const unsigned int);
74  void setTimeout(const int t_ms) { timeout = t_ms; };
75  void start();
76  char timedOut();
77 };
78 
79 
80 
81 
82 
83 
84 // *************************** Serial *************************
85 
86 class Serial
87 {
88  private:
89 #ifdef WIN32
90  OVERLAPPED ol;
91  void *portRef;
92 #else
93  struct termio oldSetup;
94  int portRef;
95 #endif
96  char frameBuffer[FRAME_BUF_SIZE];
97  int frameHead; /* chars come in here */
98  int frameTail; /* chars are read out here */
99 
100  public:
101  /* Configuring serial ports */
102  char openSerial(char*);
103  void closeSerial();
104  void flushSerial();
105 
106  /* Reading/writing serial data */
107  int readChar();
108  int readBytes(char*, const int, const int);
109  char writeChar(const char);
110  int writeString(char*);
111 };
112 
113 #endif
114