Buffer Interface
|
Wrapper around the Camera Link serial port API. More...
#include <CLAllSerial.hpp>
Classes | |
struct | PrivateData |
Public Member Functions | |
CLAllSerial (BFVOID) | |
~CLAllSerial (BFVOID) | |
BFVOID | serialInit (const CLUINT32 SerialIndex) |
BFVOID | bfSerialInit (const CLUINT32 BoardIndex) |
BFVOID | bfSWConnectorSerialInit (const CLUINT32 Switch, const CLUINT32 Connector) |
BFVOID | serialClose (BFVOID) |
BFBOOL | hasInit (BFVOID) const |
BFBOOL | hasBFSerial (BFVOID) const |
CLUINT32 | getSerialIndex (void) const |
CLUINT32 | getBoardNumber (void) const |
void | getSWConnector (CLUINT32 &Switch, CLUINT32 &Connector) const |
CLUINT32 | serialWrite (std::string const &Message, const CLUINT32 SerialTimeout) |
CLUINT32 | serialWrite (std::vector< CLINT8 > const &Buffer, const CLUINT32 SerialTimeout) |
CLUINT32 | serialWrite (const CLINT8 *const Buffer, const BFSIZET BufferLen, const CLUINT32 SerialTimeout) |
std::string | serialRead (const CLUINT32 NumBytesToRead, const CLUINT32 SerialTimeout) |
CLUINT32 | serialRead (std::vector< CLINT8 > &Buffer, const CLUINT32 ReadLen, const CLUINT32 SerialTimeout) const |
CLUINT32 | serialRead (CLINT8 *const Buffer, const CLUINT32 BufferSize, const CLUINT32 SerialTimeout) const |
BFVOID | flushPort (BFVOID) |
CLUINT32 | getNumBytesAvail (BFVOID) const |
CLUINT32 | getSupportedBaudRates (BFVOID) const |
BFVOID | setBaudRate (const CLUINT32 BaudRate) |
BFVOID | bfSerialSettings (const CLUINT32 BaudRate, const DataBits dataBits, const Parity parity, const StopBits stopBits) |
std::string | bfSerialRead (const CLUINT32 MaxBytesToRead) const |
CLUINT32 | bfSerialRead (std::vector< BFCHAR > &Buffer, const CLUINT32 MaxBytesToRead) const |
CLUINT32 | bfSerialRead (PBFCHAR Buffer, const CLUINT32 MaxBytesToRead) const |
BFVOID | bfSerialCancelRead (BFVOID) |
CLUINT32 | bfGetBaudRate (BFVOID) const |
Static Public Member Functions | |
static std::string | getErrorText (const CLINT32 ErrorCode) |
static BFBOOL | getErrorText (const CLINT32 ErrorCode, BFCHAR *const hBuf, BFSIZET *const pSize) |
static CLUINT32 | getNumPorts (BFVOID) |
static BFVOID | getPortInfo (const CLUINT32 SerialIndex, std::string &ManufacturerName, std::string &PortID, CLUINT32 &Version) |
static BFBOOL | getPortInfo (const CLUINT32 SerialIndex, BFCHAR *const ManufacturerName, BFSIZET *const pManNameSize, BFCHAR *const PortID, BFSIZET *const pPortIdSize, CLUINT32 &Version) |
static BFVOID | bfsVersion (CLUINT32 &majorVersionRef, CLUINT32 &minorVersionRef) |
Wrapper around the Camera Link serial port API.
Both the CLAllSerial.h and BFSerial.h interfaces are exposed, although the BitFlow serial functions will only be operable for ports on BitFlow boards.
CLAllSerial::CLAllSerial | ( | BFVOID | ) |
Initialize a new CLComm::CLAllSerial instance.
CLAllSerial::~CLAllSerial | ( | BFVOID | ) |
Return the current baud-rate of the CLSerial port.
BFCLException | - Thrown if an error occurs while retrieving the baud rate. |
References BFCL_ERROR_SERNOTFOUND, CLComm::BFCLException::check(), clBFGetBaudRate(), and hasBFSerial().
Cancel the active call to clBFSerialRead.
BFCLException | - Thrown if an error occurs while canceling the read. |
References BFCL_ERROR_SERNOTFOUND, CLComm::BFCLException::check(), clBFSerialCancelRead(), and hasBFSerial().
Alternate initializer, initializing from a BitFlow board index, rather than from the CLSerial port index, which may or may not directly correspond.
[in] | BoardIndex | - The index of the BitFlow board whos Camera Link serial port should be opened. |
BiException | - Thrown if an error occurs opening the frame grabber. |
BFCLException | - Thrown if an error occurs initializing the port. |
References BiTypeAny, BrdOpenOptions, BiException::check(), CLComm::BFCLException::check(), CL_ERR_NO_ERR, clBFGetSerialRefFromBoardHandle(), clBFSerialInitFromBoardHandle(), clSerialClose(), and serialClose().
std::string CLAllSerial::bfSerialRead | ( | const CLUINT32 | MaxBytesToRead | ) | const |
Reads data from the serial device. This method will wait efficiently for data to become available on the port, then return that length of data. No more than MaxBytesToRead will be read at a time, but the length read may be less than that.
[in] | MaxBytesToRead | - The maximum number of bytes to be read. |
BFCLException | - Thrown if an error occurs while reading the data. |
References BFCL_ERROR_SERNOTFOUND, CLComm::BFCLException::check(), and hasBFSerial().
Referenced by bfSerialRead().
CLUINT32 CLAllSerial::bfSerialRead | ( | std::vector< BFCHAR > & | Buffer, |
const CLUINT32 | MaxBytesToRead | ||
) | const |
Reads data from the serial device. This method will wait efficiently for data to become available on the port, then return that length of data. Returns the number of bytes read.
[out] | Buffer | - Output buffer for the data read, This will be resized to fit the data read, if necessary. |
[in] | MaxBytesToRead | - The maximum number of bytes to be read. |
BFCLException | - Thrown if an error occurs while reading the data. |
References BFCL_ERROR_SERNOTFOUND, bfSerialRead(), CLComm::BFCLException::check(), and hasBFSerial().
Reads data from the serial device. This method will wait efficiently for data to become available on the port, then return that length of data. Returns the number of bytes read.
[out] | Buffer | - Output buffer for the data read. |
[in] | MaxBytesToRead | - The maximum number of bytes to be read. Buffer should be no smaller than this byte size. |
BFCLException | - Thrown if an error occurs while reading the data. |
References BFCL_ERROR_SERNOTFOUND, CLComm::BFCLException::check(), clBFSerialRead(), and hasBFSerial().
BFVOID CLAllSerial::bfSerialSettings | ( | const CLUINT32 | BaudRate, |
const DataBits | dataBits, | ||
const Parity | parity, | ||
const StopBits | stopBits | ||
) |
Set the BF CLSerial settings.
[in] | BaudRate | - The baud rate to set, of the following options: |
[in] | dataBits | - The serial port data bits to use, of the following options: |
[in] | parity | - The serial port parity to use, of the following options: |
[in] | stopBits | - The serial port stop bits to use, of the following options: |
BFCLException | - Thrown if an error occurs while setting the settings. |
References BFCL_ERROR_SERNOTFOUND, CLComm::BFCLException::check(), clBFSerialSettings(), and hasBFSerial().
Retrieve the version of the loaded BFS library.
[out] | majorVersionRef | - Ouput integer for the major part of the version number. |
[out] | minorVersionRef | - Ouput integer for the minor part of the version number. |
BFCLException | - Thrown if an error occurs retrieving the version number. |
References BFSVersion(), and CLComm::BFCLException::check().
Alternate initializer, initializing from a BitFlow board swith and connector, rather than from the CLSerial port index, which may or may not directly correspond.
[in] | Switch | - The switch setting on the BitFlow board whos Camera Link serial port should be opened. |
[in] | Connector | - The connector index to open on the board. |
BiException | - Thrown if an error occurs opening the frame grabber. |
BFCLException | - Thrown if an error occurs initializing the port. |
References BI_CIERROR_CIBRDOPEN, BI_CIERROR_CISYSBOARDFINDSWCONNECTOR, BrdOpenOptions, BiException::check(), CLComm::BFCLException::check(), CL_ERR_NO_ERR, clBFGetSerialRefFromBoardHandle(), clBFSerialInitFromBoardHandle(), clSerialClose(), and serialClose().
Discards any bytes that are available in the input buffer.
BFCLException | - Thrown if an error occurs while flushing the serial port. |
References CLComm::BFCLException::check(), and clFlushPort().
CLUINT32 CLAllSerial::getBoardNumber | ( | void | ) | const |
|
static |
Converts an error code to error text which can be displayed in a dialog box or in the standard I/O window.
[in] | ErrorCode | - The code of the error text to retrieve. |
BFCLException | - Thrown if an error occurs retrieving the error text. |
References BFCL_ERROR_15STOP5DATA, BFCL_ERROR_2STOP5DATA, BFCL_ERROR_BAUDRATE, BFCL_ERROR_BRDNOTFOUND, BFCL_ERROR_BRDOPEN, BFCL_ERROR_BYTES_AVAIL, BFCL_ERROR_DATA_IN, BFCL_ERROR_DATABITS, BFCL_ERROR_FIFO_EN, BFCL_ERROR_FLUSH_PORT, BFCL_ERROR_NOSIGNAL, BFCL_ERROR_NOSTRUC, BFCL_ERROR_NULLPTR, BFCL_ERROR_PARITY, BFCL_ERROR_RCVRFIFO, BFCL_ERROR_SERNOTFOUND, BFCL_ERROR_STOPBITS, BFCL_ERROR_TEMT, BFCL_ERROR_THRE, BFCL_WARN_SIG_CANCEL, CLComm::BFCLException::check(), CL_ERR_BUFFER_TOO_SMALL, clGetErrorText(), and MAX_STRING.
Referenced by getErrorText().
|
static |
Converts an error code to error text which can be displayed in a dialog box or in the standard I/O window.
[in] | ErrorCode | - The code of the error text to retrieve. |
[out] | hBuf | - The string buffer pointer, filled with as much data as is possible. May be nullptr. |
[in,out] | pSize | - As input, the size of hBuf. As output, the buffer size requried. |
BFCLException | - Thrown if an error occurs retrieving the error text. |
References getErrorText().
Returns the number of bytes that are received, but not yet read out of the the serial device.
BFCLException | - Thrown if an error occurs while retrieving the number of bytes available. |
References CLComm::BFCLException::check(), and clGetNumBytesAvail().
Returns the number of Camera Link serial ports in this machine that are supported by clallserial.dll.
BFCLException | - Thrown if an error occurs retrieving port count. |
References CLComm::BFCLException::check(), and clGetNumPorts().
|
static |
Provides information about the port specified by the serial index.
[in] | SerialIndex | - The index of the serial port who's info we are retrieving. |
[out] | ManufacturerName | - Output string for the manufacturer. |
[out] | PortID | - Output string for the port ID. |
[out] | Version | - Output integer for the CLAllSerial version. |
BFCLException | - Thrown if an error occurs retrieving the port information. |
References CLComm::BFCLException::check(), CL_ERR_BUFFER_TOO_SMALL, clGetPortInfo(), and MAX_STRING.
Referenced by getPortInfo().
|
static |
Provides information about the port specified by the serial index.
[in] | SerialIndex | - The index of the serial port who's info we are retrieving. |
[out] | ManufacturerName | - Output string buffer for the manufacturer. This may be nullptr. |
[in,out] | pManNameSize | - As input, the ManufacturerName buffer size. As output, the required ManufacturerName buffer length, including null terminator. |
[out] | PortID | - Output string buffer for the port ID. This may be nullptr. |
[in,out] | pPortIdSize | - As input, the PortID buffer size. As output, the required PortID buffer length, including null terminator. |
[out] | Version | - Output integer for the CLAllSerial version. |
BFCLException | - Thrown if an error occurs retrieving the port information. |
References getPortInfo().
CLUINT32 CLAllSerial::getSerialIndex | ( | void | ) | const |
Returns the valid baud rates of the interface.
BFCLException | - Thrown if an error occurs while retrieving the supported baud rates. |
References CLComm::BFCLException::check(), and clGetSupportedBaudRates().
Retrieve the BitFlow Switch and Connector initialized, or ~CLUINT32(0), if not open or not initialized by Switch and Connector.
[out] | Switch | - Ouput integer reference set to the open board's switch setting, or ~CLUINT32(0), if not open or not initialized by Switch and Connector. |
[out] | Connector | - Output integer reference set to the open board's connector index, or ~CLUINT32(0), if not open or not initialized by Switch and Connector. |
Return whether or not the opened port supports the BitFlow CLSerial extensions.
Referenced by bfGetBaudRate(), bfSerialCancelRead(), bfSerialRead(), and bfSerialSettings().
Return whether or not a port has been initialized.
Closes the serial device and cleans up resources associated with it. Does nothing, if the device is not Initialized.
References clSerialClose().
Referenced by bfSerialInit(), bfSWConnectorSerialInit(), serialInit(), and ~CLAllSerial().
Initializes the device referred to by serialIndex. Only CL boards are considered a serial device. If the underlying CLSerial device is not a BitFlow device, the BFSerial extensions will not be enabled, and hasBFSerial will return false.
[in] | SerialIndex | - The index of the Camera Link serial port to initialize. |
BFCLException | - Thrown if an error occurs initializing the port. |
References CLComm::BFCLException::check(), clBFGetSerialRef(), clSerialInit(), and serialClose().
Reads data from the serial device.
[in] | NumBytesToRead | - The number of bytes to be read. |
[in] | SerialTimeout | - Timeout after which the read should abort. |
BFCLException | - Thrown if an error occurs reading from the serial port, including timeout. |
Referenced by serialRead().
CLUINT32 CLAllSerial::serialRead | ( | std::vector< CLINT8 > & | Buffer, |
const CLUINT32 | ReadLen, | ||
const CLUINT32 | SerialTimeout | ||
) | const |
Reads data from the serial device, returning the number of bytes read.
[out] | Buffer | - Output buffer for the data read. This will be resized to fit the data read, if necessary. |
[in] | ReadLen | - The number of bytes to be read. |
[in] | SerialTimeout | - Timeout after which the read should abort. |
BFCLException | - Thrown if an error occurs reading from the serial port, including timeout. |
References serialRead().
CLUINT32 CLAllSerial::serialRead | ( | CLINT8 *const | Buffer, |
const CLUINT32 | BufferSize, | ||
const CLUINT32 | SerialTimeout | ||
) | const |
Reads data from the serial device, returning the number of bytes read.
[out] | Buffer | - Output buffer for the data read. |
[in] | BufferSize | - Size of the output Buffer. |
[in] | SerialTimeout | - Timeout after which the read should abort. |
BFCLException | - Thrown if an error occurs reading from the serial port, including timeout. |
References CLComm::BFCLException::check(), and clSerialRead().
This method writes a string of characters to the serial device, returning the number of bytes written.
[in] | Message | - A string message to write to the port (null terminator excluded). |
[in] | SerialTimeout | - Timeout after which the write should abort. |
BFCLException | - Thrown if an error occurs writing to the serial port, including timeout. |
Referenced by serialWrite().
CLUINT32 CLAllSerial::serialWrite | ( | std::vector< CLINT8 > const & | Buffer, |
const CLUINT32 | SerialTimeout | ||
) |
This method writes data to the serial device, returning the number of bytes written.
[in] | Buffer | - Buffer of data to be written to the serial port. |
[in] | SerialTimeout | - Timeout after which the write should abort. |
BFCLException | - Thrown if an error occurs writing to the serial port, including timeout. |
References serialWrite().
CLUINT32 CLAllSerial::serialWrite | ( | const CLINT8 *const | Buffer, |
const BFSIZET | BufferLen, | ||
const CLUINT32 | SerialTimeout | ||
) |
This method writes data to the serial device, returning the number of bytes written.
[in] | Buffer | - Buffer of data to be written to the serial port. |
[in] | BufferLen | - Byte size of the data to be written. |
[in] | SerialTimeout | - Timeout after which the write should abort. |
BFCLException | - Thrown if an error occurs writing to the serial port, including timeout. |
References CLComm::BFCLException::check(), and clSerialWrite().
Sets the Baud Rate for the serial port.
[in] | BaudRate | - The baud rate to set, of the following options: |
BFCLException | - Thrown if an error occurs while setting the baud rate. |
References CLComm::BFCLException::check(), and clSetBaudRate().