Buffer Interface
clallserial.h
Go to the documentation of this file.
1 //
3 // Title : clallserial.h
4 // Created : 12/03/2003 @ 14:27:00
5 //
6 // Copyright (c) 2004. National Instruments Corporation
7 // All rights reserved.
8 //
9 // Redistribution and use in source and binary forms, with or without
10 // modification, are permitted, provided that each of the following
11 // conditions are met. By using the software in any manner, you agree
12 // to each of the following:
13 // - All redistributions of the software must be accompanied with the
14 // above copyright notice (provided however that for redistributions
15 // in binary form, the copyright notice may be omitted), the above
16 // preamble, this list of conditions, and the disclaimer set forth below.
17 // - Except for the copyright notice required above, neither the name
18 // or trademarks of National Instruments Corporation (NI) nor the names
19 // of its contributors may be used in any manner (including, but not
20 // limited to, using the same to endorse or promote products derived from
21 // this software) without the specific prior written permission of NI.
22 //
23 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24 // "AS IS" WITHOUT WARRANTY OF ANY KIND. NO WARRANTIES, EITHER EXPRESS
25 // OR IMPLIED, ARE MADE WITH RESPECT TO THE SOFTWARE, INCLUDING, BUT
26 // NOT LIMITED TO, ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
27 // FOR A PARTICULAR PURPOSE, TITLE OR NON-INFRINGEMENT, OR ANY OTHER
28 // WARRANTIES THAT MAY ARISE FROM USAGE OF TRADE OR COURSE OF DEALING.
29 // THE COPYRIGHT HOLDERS AND CONTRIBUTORS DO NOT WARRANT, GUARANTEE, OR
30 // MAKE ANY REPRESENTATIONS REGARDING THE USE OF OR THE RESULTS OF THE
31 // USE OF THE SOFTWARE IN TERMS OF CORRECTNESS, ACCURACY, RELIABILITY,
32 // OR OTHERWISE AND DO NOT WARRANT THAT THE OPERATION OF THE SOFTWARE
33 // WILL BE UNINTERRUPTED OR ERROR FREE. THE ENTIRE RISK AS TO THE
34 // PERFORMANCE OF THE SOFTWARE IS WITH YOU. IN NO EVENT SHALL THE
35 // COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
36 // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
37 // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
38 // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
39 // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
40 // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
41 // THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF ADVISED OF THE
42 // POSSIBILITY OF SUCH DAMAGE.
43 //
45 #ifndef __clallserial_h__
46 #define __clallserial_h__
47 
48 //==============================================================================
49 // Macros and Constants
50 //==============================================================================
51 #if (defined(__cplusplus) || defined(__cplusplus__))
52  #define USER_EXTERN_C extern "C"
53 #else
54  #define USER_EXTERN_C
55 #endif
56 
57 #ifdef CLALLSERIAL_EXPORTS
58  #define CLALLSERIALEXPORT USER_EXTERN_C __declspec(dllexport)
59 #else
60  #define CLALLSERIALEXPORT USER_EXTERN_C __declspec(dllimport)
61 #endif
62 
63 #ifndef CLALLSERIALCC
64  #define CLALLSERIALCC __stdcall
65 #endif
66 
67 #ifndef _CL_hSerRef_DEFINED_
68  #define _CL_hSerRef_DEFINED_
69  typedef void* hSerRef;
70 #endif
71 
72 #ifndef _CL_INT32_DEFINED_
73  #define _CL_INT32_DEFINED_
74  typedef int CLINT32;
75 #endif
76 
77 
78 #ifndef _CL_UINT32_DEFINED_
79  #define _CL_UINT32_DEFINED_
80  typedef unsigned int CLUINT32;
81 #endif
82 
83 #ifndef _CL_INT8_DEFINED_
84  #define _CL_INT8_DEFINED_
85  typedef char CLINT8;
86 #endif
87 
88 
89 //------------------------------------------------------------------------------
90 // CL serial DLL versions
91 //------------------------------------------------------------------------------
92 #define CL_DLL_VERSION_NO_VERSION 1 // Not a CL dll
93 #define CL_DLL_VERSION_1_0 2 // Oct 2000 compliant
94 #define CL_DLL_VERSION_1_1 3 // Oct 2001 compliant
95 
96 
97 //------------------------------------------------------------------------------
98 // Baud Rates
99 //------------------------------------------------------------------------------
100 #define CL_BAUDRATE_9600 1
101 #define CL_BAUDRATE_19200 2
102 #define CL_BAUDRATE_38400 4
103 #define CL_BAUDRATE_57600 8
104 #define CL_BAUDRATE_115200 16
105 #define CL_BAUDRATE_230400 32
106 #define CL_BAUDRATE_460800 64
107 #define CL_BAUDRATE_921600 128
108 
109 
110 //------------------------------------------------------------------------------
111 // Error Codes
112 //------------------------------------------------------------------------------
113 #define CL_ERR_NO_ERR 0
114 #define CL_ERR_BUFFER_TOO_SMALL -10001
115 #define CL_ERR_MANU_DOES_NOT_EXIST -10002
116 #define CL_ERR_PORT_IN_USE -10003
117 #define CL_ERR_TIMEOUT -10004
118 #define CL_ERR_INVALID_INDEX -10005
119 #define CL_ERR_INVALID_REFERENCE -10006
120 #define CL_ERR_ERROR_NOT_FOUND -10007
121 #define CL_ERR_BAUD_RATE_NOT_SUPPORTED -10008
122 #define CL_ERR_OUT_OF_MEMORY -10009
123 #define CL_ERR_REGISTRY_KEY_NOT_FOUND -10010
124 #define CL_ERR_INVALID_PTR -10011
125 #define CL_ERR_UNABLE_TO_LOAD_DLL -10098
126 #define CL_ERR_FUNCTION_NOT_FOUND -10099
127 
128 
129 //==============================================================================
130 // Exported functions
131 //==============================================================================
133 //
134 // clFlushPort
135 //
136 // Description: Discards any bytes that are available in the input
137 // buffer.
138 //
139 // Parameters:
140 // serialRef input parameter - The value obtained by the clSerialInit function
141 // that describes the port to be flushed.
142 //
143 // Return Value: CL_ERR_NO_ERR
144 // CL_ERR_INVALID_REFERENCE
145 //
148 
149 
151 //
152 // clGetErrorText
153 //
154 // Description:
155 // Converts an error code to error text which you can
156 // display in a dialog box or in the standard I/O window.
157 // Note: This function first looks up the error code in clserial.dll to determine
158 // whether it is a standard Camera Link error. If it is a non-standard error, this function
159 // passes the error code to the manufacturer-specific DLL, which returns the
160 // manufacturer-specific error code.
161 //
162 // Parameters:
163 // manuName input parameter - The manufacturer name in a NULL-terminated
164 // buffer. Manufacturer name is returned from clGetPortInfo.
165 // errorCode input parameter - The error code used to look up the
166 // appropriate error text. This code can be returned
167 // from any function in this library.
168 // errorText output parameter - A caller-allocated buffer which will contain
169 // a NULL-terminated error description on return.
170 // errorTextSize input/output parameter - As an input, this value is the size,
171 // in bytes, of the errorText buffer that is passed in. On
172 // success, this value is the number of bytes
173 // that have been written into the buffer, including the NULL
174 // termination character. On CL_ERR_BUFFER_TOO_SMALL error,
175 // this value is the size of the buffer required to write
176 // the data text.
177 //
178 // Return Value: CL_ERR_NO_ERR
179 // CL_ERR_MANU_DOES_NOT_EXIST
180 // CL_ERR_BUFFER_TOO_SMALL
181 // CL_ERR_ERROR_NOT_FOUND
182 //
184 CLALLSERIALEXPORT CLINT32 CLALLSERIALCC clGetErrorText(const CLINT8* manuName, CLINT32 errorCode, CLINT8* errorText, CLUINT32* errorTextSize);
185 
186 
188 //
189 // clGetNumPorts
190 //
191 // Description: Returns the number of Camera Link serial ports in
192 // this machine that are supported by clallserial.dll.
193 //
194 // Parameters:
195 // numPorts output parameter - The number of Camera Link serial ports
196 // in this machine supported by this DLL.
197 //
198 // Return Value: CL_ERR_NO_ERR
199 //
202 
203 
205 //
206 // clGetNumBytesAvail
207 //
208 // Description: Outputs the number of bytes that are received, but not yet read out, at
209 // the port specified by serialRef.
210 //
211 // Parameters:
212 // serialRef input - The value obtained by the clSerialInit function.
213 // numBytes output - The number of bytes currently available to be
214 // read from the port.
215 //
216 // Return Value: CL_ERR_NO_ERR
217 // CL_ERR_INVALID_REFERENCE
218 //
221 
222 
224 //
225 // clGetPortInfo
226 //
227 // Description: This function provides information about the port specified by
228 // the index.
229 //
230 // Parameters:
231 // serialIndex input parameter - Zero-based index of the serial port you are
232 // finding the name for. Use clGetNumSerialPorts to determine
233 // the valid range of serialIndex. This range will be 0 to
234 // numSerialPorts-1.
235 // manufacturerName output parameter - Pointer to a user-allocated buffer into
236 // which the fucntion copies the manufacturer name. The returned
237 // name is NULL-terminated. In the case that the DLL conforms to the
238 // version 1.0 Camera Link Specification, this
239 // parameter will contain the file name of the DLL rather than the
240 // manufacturer name.
241 // nameBytes input/output parameter - As an input parameter,
242 // this value is the size of the name buffer, including
243 // the NULL termination. As an output parameter, this value
244 // is the number of bytes written into the name buffer.
245 // If the provided name buffer is not large enough, this value
246 // is the number of required bytes.
247 // portID output parameter - The identifier for the port. For now, this
248 // value is the interface name. In the future, there may be an
249 // extension for multiple serial ports on one board.
250 // IDBytes input/output parameter. As an input parameter, this value is
251 // the size of the portID buffer, including
252 // the NULL termination. As an output parameter, this value is
253 // the number of bytes written into the portID buffer.
254 // If the provided portID buffer is not large enough, this value is
255 // the number of required bytes.
256 //
257 // Return Value: CL_ERR_NO_ERR
258 // CL_ERR_BUFFER_TOO_SMALL
259 // CL_ERR_INVALID_INDEX//
261 CLALLSERIALEXPORT CLINT32 CLALLSERIALCC clGetPortInfo(CLUINT32 serialIndex, CLINT8* manufacturerName, CLUINT32* nameBytes, CLINT8* portID, CLUINT32* IDBytes, CLUINT32* version);
262 
263 
265 //
266 // clGetSupportedBaudRates
267 //
268 // Description: Returns the valid baud rates of the interface.
269 //
270 // Parameters:
271 // serialRefPtr input parameter - The value obtained from
272 // clSerialInit function.
273 // baudRates output parameter - Indicates which baud
274 // rates are supported by this serial interface. This
275 // is represented as a bitfield. Refer to the CL_BAUDRATE_
276 // constants above for the supported baud rates.
277 //
278 // Return Value: CL_ERR_NO_ERR
279 // CL_ERR_INVALID_REFERENCE
280 // CL_ERR_FUNCTION_NOT_FOUND
281 //
284 
285 
287 //
288 // clSerialClose
289 //
290 // Description: Closes the serial device and cleans up resources associated
291 // with serialRef. Upon return, serialRef is no longer usable.
292 //
293 // Parameters:
294 // serialRef input parameter - The value obtained from clSerialInit
295 // function to clean up.
296 //
299 
300 
302 //
303 // clSerialInit
304 //
305 // Description:
306 // Initializes the device referred to by serialIndex, and
307 // returns a pointer to an internal serial reference structure.
308 //
309 // Parameters:
310 // serialIndex input parameter - Zero-based index value. If there are n
311 // serial devices in the system that is supported by this
312 // library, the range of serialIndex is 0 to (n-1).
313 // The order of the serial devices is vendor-specific. The
314 // number of serial ports supported by this DLL is
315 // output by the clGetNumSerialPorts function.
316 // serialRefPtr output parameter - Upon a successful call, a pointer to the
317 // vendor-specific reference to the current serial session
318 // will be put into the value pointed to by serialRefPtr.
319 //
320 // Return Value: CL_ERR_NO_ERR
321 // CL_ERR_PORT_IN_USE
322 // CL_ERR_INVALID_INDEX
323 // CL_ERR_UNABLE_TO_OPEN_PORT
324 //
327 
328 
330 //
331 // clSerialRead
332 //
333 // Description: Reads from the serial device referenced by serialRef.
334 //
335 // Parameters:
336 // serialRef input parameter - The value obtained from clSerialInit function
337 // buffer output parameter - Points to a user-allocated buffer.
338 // Upon a successful call, contains the data
339 // read from the serial device.
340 // bufferSize input-output parameter - As an input parameter, bufferSize contains the
341 // buffer size to indicate the maximum number of bytes that
342 // the buffer can accomodate.
343 // Upon a successful call, bufferSize is the
344 // number of bytes that were read successfully from the
345 // serial device.
346 // serialTimeout input parameter - Indicates the timeout, in milliseconds
347 //
348 // Return value CL_ERR_NO_ERR
349 // CL_ERR_TIMEOUT
350 // CL_ERR_INVALID_REFERENCE
351 //
353 CLALLSERIALEXPORT CLINT32 CLALLSERIALCC clSerialRead(hSerRef serialRef, CLINT8* buffer, CLUINT32* bufferSize, CLUINT32 serialTimeout);
354 
355 
357 //
358 // clSerialWrite
359 //
360 // Description: This function writes data in buffer to the serial device
361 // referenced by serialRef.
362 //
363 // Parameters:
364 // serialRef input parameter - The value obtained from clSerialInit function
365 // buffer input parameter - Contains data to write to the serial port
366 // bufferSize input/output parameter - As an input parameter, bufferSize contains the
367 // number of bytes of data in the buffer to write to the
368 // serial device. Upon a successful call, bufferSize contains the
369 // number of bytes that was written successfully to the
370 // serial device.
371 // serialTimeout input parameter - Indicates the timeout, in miliseconds
372 //
373 // Return value: CL_ERR_NO_ERR
374 // CL_ERR_INVALID_REFERENCE
375 // CL_ERR_TIMEOUT
377 CLALLSERIALEXPORT CLINT32 CLALLSERIALCC clSerialWrite(hSerRef serialRef, CLINT8* buffer, CLUINT32* bufferSize, CLUINT32 serialTimeout);
378 
379 
381 //
382 // clSetBaudRate
383 //
384 // Description: Sets the Baud Rate for the serial port of the
385 // selected port. Use clGetSupportedBaudRates to deterimine
386 // supported baud rates.
387 //
388 // Parameters:
389 // serialRef input parameter - The value obtained from
390 // clSerialInit function.
391 // baudRate input parameter - The baud rate you want to use. This
392 // input expects the values represented by the CL_BAUDRATE
393 // constants.
394 //
395 // Return Value: CL_ERR_NO_ERR
396 // CL_ERR_INVALID_REFERENCE
397 // CL_ERR_BAUD_RATE_NOT_SUPPORTED
398 //
401 
402 //==============================================================================
403 // the endif
404 //==============================================================================
405 #endif
CLALLSERIALEXPORT CLINT32 CLALLSERIALCC clGetNumBytesAvail(hSerRef serialRef, CLUINT32 *numBytes)
CLALLSERIALEXPORT CLINT32 CLALLSERIALCC clFlushPort(hSerRef serialRef)
CLALLSERIALEXPORT void CLALLSERIALCC clSerialClose(hSerRef serialRef)
unsigned int CLUINT32
Definition: clallserial.h:80
CLALLSERIALEXPORT CLINT32 CLALLSERIALCC clGetNumPorts(CLUINT32 *Ports)
#define CLALLSERIALEXPORT
Definition: clallserial.h:60
#define CLALLSERIALCC
Definition: clallserial.h:64
CLALLSERIALEXPORT CLINT32 CLALLSERIALCC clSerialRead(hSerRef serialRef, CLINT8 *buffer, CLUINT32 *bufferSize, CLUINT32 serialTimeout)
void * hSerRef
Definition: clallserial.h:69
CLALLSERIALEXPORT CLINT32 CLALLSERIALCC clSetBaudRate(hSerRef serialRef, CLUINT32 baudRate)
CLALLSERIALEXPORT CLINT32 CLALLSERIALCC clGetSupportedBaudRates(hSerRef serialRef, CLUINT32 *baudRates)
int CLINT32
Definition: clallserial.h:74
CLALLSERIALEXPORT CLINT32 CLALLSERIALCC clGetPortInfo(CLUINT32 serialIndex, CLINT8 *manufacturerName, CLUINT32 *nameBytes, CLINT8 *portID, CLUINT32 *IDBytes, CLUINT32 *version)
CLALLSERIALEXPORT CLINT32 CLALLSERIALCC clSerialWrite(hSerRef serialRef, CLINT8 *buffer, CLUINT32 *bufferSize, CLUINT32 serialTimeout)
CLALLSERIALEXPORT CLINT32 CLALLSERIALCC clSerialInit(CLUINT32 serialIndex, hSerRef *serialRefPtr)
char CLINT8
Definition: clallserial.h:85
CLALLSERIALEXPORT CLINT32 CLALLSERIALCC clGetErrorText(const CLINT8 *manuName, CLINT32 errorCode, CLINT8 *errorText, CLUINT32 *errorTextSize)