NifTK  16.4.1 - 0798f20
CMIC's Translational Medical Imaging Platform
ndicapi_serial.h
Go to the documentation of this file.
1 /*=======================================================================
2 
3  Program: NDI Combined API C Interface Library
4  Module: $RCSfile: ndicapi_serial.h,v $
5  Creator: David Gobbi <dgobbi@atamai.com>
6  Language: C
7  Author: $Author: kcharbon $
8  Date: $Date: 2008/06/18 15:33:20 $
9  Version: $Revision: 1.6 $
10 
11 ==========================================================================
12 
13 Copyright (c) 2000-2005 Atamai, Inc.
14 
15 Use, modification and redistribution of the software, in source or
16 binary forms, are permitted provided that the following terms and
17 conditions are met:
18 
19 1) Redistribution of the source code, in verbatim or modified
20  form, must retain the above copyright notice, this license,
21  the following disclaimer, and any notices that refer to this
22  license and/or the following disclaimer.
23 
24 2) Redistribution in binary form must include the above copyright
25  notice, a copy of this license and the following disclaimer
26  in the documentation or with other materials provided with the
27  distribution.
28 
29 3) Modified copies of the source code must be clearly marked as such,
30  and must not be misrepresented as verbatim copies of the source code.
31 
32 THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE "AS IS"
33 WITHOUT EXPRESSED OR IMPLIED WARRANTY INCLUDING, BUT NOT LIMITED TO,
34 THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
35 PURPOSE. IN NO EVENT SHALL ANY COPYRIGHT HOLDER OR OTHER PARTY WHO MAY
36 MODIFY AND/OR REDISTRIBUTE THE SOFTWARE UNDER THE TERMS OF THIS LICENSE
37 BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL OR CONSEQUENTIAL DAMAGES
38 (INCLUDING, BUT NOT LIMITED TO, LOSS OF DATA OR DATA BECOMING INACCURATE
39 OR LOSS OF PROFIT OR BUSINESS INTERRUPTION) ARISING IN ANY WAY OUT OF
40 THE USE OR INABILITY TO USE THE SOFTWARE, EVEN IF ADVISED OF THE
41 POSSIBILITY OF SUCH DAMAGES.
42 
43 =======================================================================*/
44 
50 #ifndef NDICAPI_SERIAL_H
51 #define NDICAPI_SERIAL_H 1
52 
53 #ifdef __cplusplus
54 extern "C" {
55 #endif
56 
57 /*=====================================================================*/
69 #ifdef _WIN32
70 
71 #include <windows.h>
72 typedef HANDLE NDIFileHandle;
73 #define NDI_INVALID_HANDLE INVALID_HANDLE_VALUE
74 
75 #elif defined(unix) || defined(__unix__) || defined(__APPLE__)
76 
77 typedef int NDIFileHandle;
78 #define NDI_INVALID_HANDLE -1
79 
80 #if defined(linux) || defined(__linux__)
81 #define NDI_NUMBER_OF_DEVICES 7
82 #define NDI_DEVICE0 "/dev/ttyS0"
83 #define NDI_DEVICE1 "/dev/ttyS1"
84 #define NDI_DEVICE2 "/dev/ttyUSB0"
85 #define NDI_DEVICE3 "/dev/ttyUSB1"
86 #define NDI_DEVICE4 "/dev/ttyUSB2"
87 #define NDI_DEVICE5 "/dev/ttyUSB3"
88 #define NDI_DEVICE6 "/dev/ttyUSB4"
89 #define NDI_DEVICE7 "/dev/ttyUSB5"
90 
91 #elif defined(__APPLE__)
92 #define NDI_NUMBER_OF_DEVICES 0
93 #elif defined(sgi)
94 #define NDI_NUMBER_OF_DEVICES 4
95 #define NDI_DEVICE0 "/dev/ttyd1"
96 #define NDI_DEVICE1 "/dev/ttyd2"
97 #define NDI_DEVICE2 "/dev/ttyd3"
98 #define NDI_DEVICE3 "/dev/ttyd4"
99 #define NDI_DEVICE4 "/dev/ttyd5"
100 #define NDI_DEVICE5 "/dev/ttyd6"
101 #define NDI_DEVICE6 "/dev/ttyd7"
102 #define NDI_DEVICE7 "/dev/ttyd8"
103 #else
104 #define NDI_NUMBER_OF_DEVICES 2
105 #define NDI_DEVICE0 "/dev/ttya"
106 #define NDI_DEVICE1 "/dev/ttyb"
107 #endif
108 
109 #elif defined(macintosh)
110 
111 typedef long NDIFileHandle;
112 #define NDI_INVALID_HANDLE -1
113 /* macros to extract input and output file handles */
114 #define output_file(serial_port) ((short)((serial_port & 0xff00) >> 16));
115 #define input_file(serial_port) ((short)((serial_port & 0x00ff) >> 0));
116 
117 #define NDI_NUMBER_OF_DEVICES 2
118 #define NDI_DEVICE0 "\p.A"
119 #define NDI_DEVICE1 "\p.B"
120 
121 #endif
122 
133 NDIFileHandle ndiSerialOpen(const char *device);
134 
141 void ndiSerialClose(NDIFileHandle serial_port);
142 
148 int ndiSerialCheckDSR(NDIFileHandle serial_port);
149 
161 int ndiSerialBreak(NDIFileHandle serial_port);
162 
172 int ndiSerialFlush(NDIFileHandle serial_port, int flushtype);
173 
174 #define NDI_IFLUSH 0x1
175 #define NDI_OFLUSH 0x2
176 #define NDI_IOFLUSH 0x3
177 
201 int ndiSerialComm(NDIFileHandle serial_port, int baud, const char *mode,
202  int handshake);
203 
212 int ndiSerialTimeout(NDIFileHandle serial_port, int milliseconds);
213 
226 int ndiSerialWrite(NDIFileHandle serial_port, const char *text, int n);
227 
241 int ndiSerialRead(NDIFileHandle serial_port, char *reply, int n);
242 
248 int ndiSerialSleep(NDIFileHandle serial_port, int milliseconds);
249 
250 #ifdef __cplusplus
251 }
252 #endif
253 
254 #endif /* NDICAPI_SERIAL_H */
int ndiSerialFlush(NDIFileHandle serial_port, int flushtype)
GLenum mode
Definition: glew.h:2404
int ndiSerialBreak(NDIFileHandle serial_port)
int ndiSerialComm(NDIFileHandle serial_port, int baud, const char *mode, int handshake)
void ndiSerialClose(NDIFileHandle serial_port)
NDIFileHandle ndiSerialOpen(const char *device)
int ndiSerialTimeout(NDIFileHandle serial_port, int milliseconds)
int ndiSerialWrite(NDIFileHandle serial_port, const char *text, int n)
GLclampd n
Definition: glew.h:6789
int ndiSerialRead(NDIFileHandle serial_port, char *reply, int n)
int ndiSerialCheckDSR(NDIFileHandle serial_port)
int ndiSerialSleep(NDIFileHandle serial_port, int milliseconds)
typedef HANDLE(WINAPI *PFNWGLCREATEBUFFERREGIONARBPROC)(HDC hDC