EDT PDV SDK Documentation 6.1.0
libclseredt.h File Reference

(git b1678dc, 2023-03-15)

The EDT-specific library to interact with Camera Link serial ports on EDT VisionLink devices. More...

Macros

#define CL_ERR_NO_ERR   0
 
#define CL_ERR_BUFFER_TOO_SMALL   (-10001)
 
#define CL_ERR_MANU_DOES_NOT_EXIST   (-10002)
 
#define CL_ERR_PORT_IN_USE   (-10003)
 
#define CL_ERR_TIMEOUT   (-10004)
 
#define CL_ERR_INVALID_INDEX   (-10005)
 
#define CL_ERR_INVALID_REFERENCE   (-10006)
 
#define CL_ERR_ERROR_NOT_FOUND   (-10007)
 
#define CL_ERR_BAUD_RATE_NOT_SUPPORTED   (-10008)
 
#define CL_ERR_OUT_OF_MEMORY   (-10009)
 
#define CL_ERR_REGISTRY_KEY_NOT_FOUND   (-10010)
 
#define CL_ERR_INVALID_PTR   (-10011)
 
#define CL_ERR_UNABLE_TO_LOAD_DLL   (-10098)
 
#define CL_ERR_FUNCTION_NOT_FOUND   (-10099)
 
#define CL_ERR_EDT_NOT_INITIALIZED   (-12301)
 

Typedefs

typedef void * hSerRef
 
typedef int CLINT32
 
typedef unsigned int CLUINT32
 
typedef char CLINT8
 

Functions

CLSEREDT_API CLINT32 clFlushPort (hSerRef serialRef)
 Discard any bytes that are available in the serial input buffer. More...
 
CLSEREDT_API CLINT32 clGetErrorText (const CLINT8 *mfgName, CLINT32 errorCode, CLINT8 *errorText, CLUINT32 *errorTextSizeconst)
 Converts an error code to error text. More...
 
CLSEREDT_API CLINT32 clGetNumPorts (CLUINT32 *numPorts)
 An alias of clGetNumSerialPorts() More...
 
CLSEREDT_API CLINT32 clGetNumSerialPorts (CLUINT32 *numPorts)
 Get the number of Camera Link serial ports supported by this (EDT) library. More...
 
CLSEREDT_API CLINT32 clGetNumBytesAvail (hSerRef serialRef, CLUINT32 *numBytes)
 Get the number of bytes available in the serial RX buffer. More...
 
CLSEREDT_API CLINT32 clGetPortInfo (CLUINT32 serialIndex, CLINT8 *manufacturerName, CLUINT32 *nameBytes, CLINT8 *portID, CLUINT32 *IDBytes, CLUINT32 *version)
 Get information about the serial port. More...
 
CLSEREDT_API CLINT32 clGetSupportedBaudRates (hSerRef serialRef, CLUINT32 *baudRates)
 Get a list of baud rates that are valid for a given serial interface. More...
 
CLSEREDT_API void clSerialClose (hSerRef serialRef)
 Close the serial interface and free associated resources. Upon return serialRef is no longer usable. More...
 
CLSEREDT_API CLINT32 clSerialInit (CLUINT32 serialIndex, hSerRef *serialRefPtr)
 Initialize the device indicated by the serialIndex and return a pointer handle to the serial port. More...
 
CLSEREDT_API CLINT32 clSerialRead (hSerRef serialRef, CLINT8 *buffer, CLUINT32 *bufferSize, CLUINT32 serialTimeout)
 Read from the serial device. More...
 
CLSEREDT_API CLINT32 clSerialWrite (hSerRef serialRef, CLINT8 *buffer, CLUINT32 *bufferSize, CLUINT32 serialTimeout)
 Write data to the serial device. More...
 
CLSEREDT_API CLINT32 clSetBaudRate (hSerRef serialRef, CLUINT32 baudRate)
 Set the baud rate of the serial port. More...
 

Detailed Description

The EDT-specific library to interact with Camera Link serial ports on EDT VisionLink devices.

The "clallserial.dll" library, defined by the Camera Link (tm) standard, will find and load this EDT-specific library. Users should be interacting with "clallserial.dll", not this library.


(clallser.h, created 12/03/2003 @ 14:27:00)

Copyright (c) 2004. National Instruments Corporation All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted, provided that each of the following conditions are met. By using the software in any manner, you agree to each of the following:

  • All redistributions of the software must be accompanied with the above copyright notice (provided however that for redistributions in binary form, the copyright notice may be omitted), the above preamble, this list of conditions, and the disclaimer set forth below.
  • Except for the copyright notice required above, neither the name or trademarks of National Instruments Corporation (NI) nor the names of its contributors may be used in any manner (including, but not limited to, using the same to endorse or promote products derived from this software) without the specific prior written permission of NI.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" WITHOUT WARRANTY OF ANY KIND. NO WARRANTIES, EITHER EXPRESS OR IMPLIED, ARE MADE WITH RESPECT TO THE SOFTWARE, INCLUDING, BUT NOT LIMITED TO, ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE OR NON-INFRINGEMENT, OR ANY OTHER WARRANTIES THAT MAY ARISE FROM USAGE OF TRADE OR COURSE OF DEALING. THE COPYRIGHT HOLDERS AND CONTRIBUTORS DO NOT WARRANT, GUARANTEE, OR MAKE ANY REPRESENTATIONS REGARDING THE USE OF OR THE RESULTS OF THE USE OF THE SOFTWARE IN TERMS OF CORRECTNESS, ACCURACY, RELIABILITY, OR OTHERWISE AND DO NOT WARRANT THAT THE OPERATION OF THE SOFTWARE WILL BE UNINTERRUPTED OR ERROR FREE. THE ENTIRE RISK AS TO THE PERFORMANCE OF THE SOFTWARE IS WITH YOU. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

MODIFIED 2023 by Engineering Design Team, Inc.

Macro Definition Documentation

◆ CL_ERR_NO_ERR

#define CL_ERR_NO_ERR   0

No error.

◆ CL_ERR_BUFFER_TOO_SMALL

#define CL_ERR_BUFFER_TOO_SMALL   (-10001)

Size of the buffer passed in is not large enough.

◆ CL_ERR_MANU_DOES_NOT_EXIST

#define CL_ERR_MANU_DOES_NOT_EXIST   (-10002)

Requested manufacturer DLL does not exist.

◆ CL_ERR_PORT_IN_USE

#define CL_ERR_PORT_IN_USE   (-10003)

Requested port is currently in use.

◆ CL_ERR_TIMEOUT

#define CL_ERR_TIMEOUT   (-10004)

Operation timed out.

◆ CL_ERR_INVALID_INDEX

#define CL_ERR_INVALID_INDEX   (-10005)

Index is not valid.

◆ CL_ERR_INVALID_REFERENCE

#define CL_ERR_INVALID_REFERENCE   (-10006)

Serial reference (pointer) is not valid.

◆ CL_ERR_ERROR_NOT_FOUND

#define CL_ERR_ERROR_NOT_FOUND   (-10007)

A description for the provided error code was not found.

◆ CL_ERR_BAUD_RATE_NOT_SUPPORTED

#define CL_ERR_BAUD_RATE_NOT_SUPPORTED   (-10008)

Baud rate is unsupported.

◆ CL_ERR_OUT_OF_MEMORY

#define CL_ERR_OUT_OF_MEMORY   (-10009)

A memory allocation failed.

◆ CL_ERR_REGISTRY_KEY_NOT_FOUND

#define CL_ERR_REGISTRY_KEY_NOT_FOUND   (-10010)

Could not find the cameralink registry key in (Windows) system registry.

◆ CL_ERR_INVALID_PTR

#define CL_ERR_INVALID_PTR   (-10011)

Pointer is invalid.

◆ CL_ERR_UNABLE_TO_LOAD_DLL

#define CL_ERR_UNABLE_TO_LOAD_DLL   (-10098)

Could not load a DLL. Potential reasons include missing API functions or a lack of memory.

◆ CL_ERR_FUNCTION_NOT_FOUND

#define CL_ERR_FUNCTION_NOT_FOUND   (-10099)

Function does not exists in the manufacturer's library.

◆ CL_ERR_EDT_NOT_INITIALIZED

#define CL_ERR_EDT_NOT_INITIALIZED   (-12301)

EDT board has not been initalized yet.

Typedef Documentation

◆ hSerRef

typedef void* hSerRef

Generic pointer type

◆ CLINT32

typedef int CLINT32

(signed) 32-bit integer type

◆ CLUINT32

typedef unsigned int CLUINT32

(unsigned) 32-bit integer type

◆ CLINT8

typedef char CLINT8

8-bit integer type

Function Documentation

◆ clFlushPort()

CLSEREDT_API CLINT32 clFlushPort ( hSerRef  serialRef)

Discard any bytes that are available in the serial input buffer.

Parameters
[in]serialRefThe value from clSerialInit that describes the port to be flushed.
Returns
CL_ERR_NO_ERR if successful.

◆ clGetErrorText()

CLSEREDT_API CLINT32 clGetErrorText ( const CLINT8 mfgName,
CLINT32  errorCode,
CLINT8 errorText,
CLUINT32 errorTextSizeconst 
)

Converts an error code to error text.

Parameters
[in]mfgNameThe manufacturer name in a NULL-terminated buffer, as returned from clGetPortInfo.
[in]errorCodeThe error code to get a text description of.
[out]errorTextA caller-allocated buffer which returns the NULL-terminated error text.
[in,out]errorTextSizeconstOn success, contains the number of bytes written into the buffer, including the NULL-termination character. This value should be the size in bytes of the error text buffer passed in. On CL_ERR_BUFFER_TOO_SMALL, contains the size of the buffer needed to write the error text.
Returns
CL_ERR_NO_ERR if successful.

◆ clGetNumPorts()

CLSEREDT_API CLINT32 clGetNumPorts ( CLUINT32 numPorts)

An alias of clGetNumSerialPorts()

Due to inconsistency in the spec between VB and C++ versions, this function was added to the clser EDT library. It simply calls clGetNumSerialPorts().

◆ clGetNumSerialPorts()

CLSEREDT_API CLINT32 clGetNumSerialPorts ( CLUINT32 numPorts)

Get the number of Camera Link serial ports supported by this (EDT) library.

Note
(EDT library) Always assumes base mode and returns 2 ports per board. If medium/full mode cameras are in use, only the even-numbered serial port indexes should be used.
Parameters
[out]numPortsNumber of serial supported serial ports.
Returns
CL_ERR_NO_ERR if successful.

◆ clGetNumBytesAvail()

CLSEREDT_API CLINT32 clGetNumBytesAvail ( hSerRef  serialRef,
CLUINT32 numBytes 
)

Get the number of bytes available in the serial RX buffer.

Parameters
[in]serialRefSerial port reference pointer.
See also
clSerialInit()
Parameters
[out]numBytesNumber of bytes avaliable to be read.
Returns
CL_ERR_NO_ERR if successful.

◆ clGetPortInfo()

CLSEREDT_API CLINT32 clGetPortInfo ( CLUINT32  serialIndex,
CLINT8 manufacturerName,
CLUINT32 nameBytes,
CLINT8 portID,
CLUINT32 IDBytes,
CLUINT32 version 
)

Get information about the serial port.

Parameters
[in]serialIndexIndex of the serial port to query. Should be in the range of 0 to N-1, where N is the value returned by clGetNumSerialPorts().
[out]manufacturerNamePointer of a caller-allocated buffer which this function will write the NULL-terminated manufacturer name.
[in,out]nameBytesPass in the size of the nameBytes buffer. Returns the number of bytes written to the buffer, including the NULL terminating character. If CL_ERR_BUFFER_TOO_SMALL is returned, this will be set to the buffer size that would be needed to write all the data.
[out]portIDEDT-specific identifier of the serial port.
[in,out]IDBytesPass in the size of the portID buffer. Returns the number of bytes written io the buffer, including the NULL terminating character. If CL_ERR_BUFFER_TOO_SMALL is returned, this will be set to the buffer size that would be needed to write all the data.
[out]versionVersion of the Camera Link(tm) specification which this library is compatible with.
Returns
CL_ERR_NO_ERR if successful.

◆ clGetSupportedBaudRates()

CLSEREDT_API CLINT32 clGetSupportedBaudRates ( hSerRef  serialRef,
CLUINT32 baudRates 
)

Get a list of baud rates that are valid for a given serial interface.

Parameters
[in]serialRefSerial port reference pointer.
See also
clSerialInit()
Parameters
[out]baudRatesSupported baud rates, represented as a bitfield. Refer to the CL_BAUDRATE_* defines.
Returns
CL_ERR_NO_ERR if successful.

◆ clSerialClose()

CLSEREDT_API void clSerialClose ( hSerRef  serialRef)

Close the serial interface and free associated resources. Upon return serialRef is no longer usable.

Parameters
[in]serialRefSerial port reference pointer.
See also
clSerialInit()

◆ clSerialInit()

CLSEREDT_API CLINT32 clSerialInit ( CLUINT32  serialIndex,
hSerRef serialRefPtr 
)

Initialize the device indicated by the serialIndex and return a pointer handle to the serial port.

Parameters
[in]serialIndexIndex of the serial port to open. Should be in the range of 0 to N-1, where N is the value returned by clGetNumSerialPorts(). The order of serial devices is vendor-specific.
[out]serialRefPtrIf successful, this will return a handle to the serial device.
Returns
CL_ERR_NO_ERR if successful.

◆ clSerialRead()

CLSEREDT_API CLINT32 clSerialRead ( hSerRef  serialRef,
CLINT8 buffer,
CLUINT32 bufferSize,
CLUINT32  serialTimeout 
)

Read from the serial device.

Parameters
[in]serialRefSerial port reference pointer.
See also
clSerialInit()
Parameters
[out]bufferA caller-allocated buffer. The data read from the serial port will be written to this buffer if the operation is successful.
[in,out]bufferSizePass in the size, in bytes, of buffer. If the read operation is successful, the actual number of bytes written into buffer is returned.
[in]serialTimeoutIndicates the read operation timeout, in milliseconds.
Returns
CL_ERR_NO_ERR if successful.

◆ clSerialWrite()

CLSEREDT_API CLINT32 clSerialWrite ( hSerRef  serialRef,
CLINT8 buffer,
CLUINT32 bufferSize,
CLUINT32  serialTimeout 
)

Write data to the serial device.

Parameters
[in]serialRefSerial port reference pointer.
See also
clSerialInit()
Parameters
[in]bufferData to write to the serial port.
[in,out]bufferSizePass in the size, in bytes, of buffer. If the write operation is successful, this contains the actual number of bytes written.
[in]serialTimeoutIndicates the write operation timeout, in milliseconds.
Returns
CL_ERR_NO_ERR if successful.

◆ clSetBaudRate()

CLSEREDT_API CLINT32 clSetBaudRate ( hSerRef  serialRef,
CLUINT32  baudRate 
)

Set the baud rate of the serial port.

Query the baud rates supported by this port by calling clGetSupportedBaudRates().

For example:

hSerRef ser = NULL;
clSerialInit(0, &ser);
uint32_t supported_baud_rates = 0;
clGetSupportedBaudRates(ser, &supported_baud_rates)
if (CL_BAUDRATE_115200 & supported_baud_rates)
clSetBaudRate(ser, CL_BAUDRATE_115200);
else if (CL_BAUDRATE_9600 & supported_baud_rates)
clSetBaudRate(ser, CL_BAUDRATE_9600);
Parameters
[in]serialRefSerial port reference pointer.
See also
clSerialInit()
Parameters
[in]baudRateThe baud rate to set. Should be one of the CL_BAUDRATE_* defines.
Returns
CLSEREDT_API