Pleora Technologies Inc. eBUS SDK v6.2.8.5877 API



PvDeviceSerialPort Class Reference

Provides access the a serial port on a Pleora GigE Vision or USB3 Vision device. More...

Public Member Functions

 PvDeviceSerialPort ()
 Constructor.
 
virtual ~PvDeviceSerialPort ()
 Destructor.
 
PvResult Open (IPvDeviceAdapter *aDevice, PvDeviceSerial aPort)
 Opens the serial port. More...
 
PvResult Close ()
 Closes the serial port. More...
 
bool IsOpened ()
 Returns true if the serial port is opened. More...
 
PvResult Write (const uint8_t *aBuffer, uint32_t aSize, uint32_t &aBytesWritten)
 Writes data to the serial port. More...
 
PvResult GetWriteProgress (uint32_t &aWritten, uint32_t &aTotal)
 Gets the progress of an ongoing write operation. More...
 
PvResult Read (uint8_t *aBuffer, uint32_t aBufferSize, uint32_t &aBytesRead, uint32_t aTimeout=0)
 Reads from the serial port. More...
 
PvResult NotifyReadComplete ()
 Method used to trigger a OnReadComplete event to PvDeviceSerialPortEchoSink subscribers. More...
 
PvResult FlushRxBuffer ()
 Empties the read buffer. More...
 
PvResult GetRxBytesReady (uint32_t &aBytes)
 Returns the number of bytes in the read buffer. More...
 
PvResult GetRxBufferSize (uint32_t &aSize)
 Returns the current capacity of the receive buffer. More...
 
PvResult SetRxBufferSize (uint32_t aSize)
 Sets the capacity of the receive buffer. The receive buffer needs to be big enough to buffer all incoming bytes before the user calls Read Resizing the receive buffer flushes all data in that buffer. More...
 
uint64_t GetBytesSent () const
 Returns how many bytes were sent through the serial port. More...
 
uint64_t GetBytesReceived () const
 Returns how many bytes were received from the serial port. More...
 
void ResetStatistics ()
 Resets the port statistics.
 

Static Public Member Functions

static bool IsSupported (IPvDeviceAdapter *aDevice, PvDeviceSerial aPort)
 Tests if a specific serial port is supported on a device. More...
 
static PvResult RegisterEchoSink (PvDeviceSerialPortEchoSink *aSink)
 Registers an echo sink for all device serial communication in the process. More...
 
static PvResult UnregisterEchoSink (PvDeviceSerialPortEchoSink *aSink)
 Unregisters an echo sink for all device serial communication in the process. More...
 

Detailed Description

Provides access the a serial port on a Pleora GigE Vision or USB3 Vision device.

PvDeviceSerialPort uses a proprietary serial communication protocol on top of GigE Vision's GVCP or USB3 Vision's GenCP protocol. It does not support non-Pleora devices.

Use of the PvDeviceSerialPort class to directly access the camera head will interfere with the synchronization between the device and the camera head. Avoid accessing device features linked to the camera head while using the PvDeviceSerialPort class to interact with the camera head.

How to use this class

To use a serial port:

  1. Connect to a device using any of the PvDevice::Connect methods.
  2. Open a serial port to the device using PvDeviceSerialPort::Open.
  3. Write to the serial port using PvSerialPort::Write.
  4. Read from the serial port using PvSerialPort::Read.
  5. Finally close the serial port using PvDeviceSerialPort::Close.

To check if a device supports a specific serial port:

  1. Connect to a device using any of the PvDevice::Connect methods.
  2. Use the PvDeviceSerialPort::IsSupported static method.

For a simple example illustrating how to use PvDeviceSerialPort, refer to the sample entitled DeviceSerialPort.

Member Function Documentation

PvResult PvDeviceSerialPort::Close ( )

Closes the serial port.

Returns
Includes:
PvResult PvDeviceSerialPort::FlushRxBuffer ( )

Empties the read buffer.

Returns
Includes:
uint64_t PvDeviceSerialPort::GetBytesReceived ( ) const

Returns how many bytes were received from the serial port.

Returns
Bytes received.
uint64_t PvDeviceSerialPort::GetBytesSent ( ) const

Returns how many bytes were sent through the serial port.

Returns
Bytes sent.
PvResult PvDeviceSerialPort::GetRxBufferSize ( uint32_t &  aSize)

Returns the current capacity of the receive buffer.

If more data than the receive buffer's capacity is received before being read using Read, oldest bytes are dropped first.

Parameters
[out]aSizeCurrent capacity of the receive buffer.
Returns
Includes:
PvResult PvDeviceSerialPort::GetRxBytesReady ( uint32_t &  aBytes)

Returns the number of bytes in the read buffer.

Parameters
[out]aBytesNumber of bytes currently queued in the receive buffer.
Returns
Includes:
PvResult PvDeviceSerialPort::GetWriteProgress ( uint32_t &  aWritten,
uint32_t &  aTotal 
)

Gets the progress of an ongoing write operation.

This method can be called from a different thread than the blocking Write call in order track or report the progress of the operation.

After a successful write operation, this method returns aWritten equals to aTotal until the begining of the next write operation.

Parameters
[out]aWrittenHow many bytes have been written up to now.
[out]aTotalTotal number of bytes to write.
Returns
Includes:
bool PvDeviceSerialPort::IsOpened ( )

Returns true if the serial port is opened.

Returns
True if the port is opened.
bool PvDeviceSerialPort::IsSupported ( IPvDeviceAdapter aDevice,
PvDeviceSerial  aPort 
)
static

Tests if a specific serial port is supported on a device.

This static method can be used to probe which serial ports are supported by a specific PvDevice.

Parameters
[in]aDevicePointer to a PvDevice object. The device must be connected.
[in]aPortPvDeviceSerial enumeration value representing the device's serial port.
Returns
True if supported.
PvResult PvDeviceSerialPort::NotifyReadComplete ( )

Method used to trigger a OnReadComplete event to PvDeviceSerialPortEchoSink subscribers.

Returns
Includes:
PvResult PvDeviceSerialPort::Open ( IPvDeviceAdapter aDevice,
PvDeviceSerial  aPort 
)

Opens the serial port.

The Open method opens a serial port to a device - mainly configuring it for serial communication readiness.

Parameters
[in]aDevicePointer to a PvDevice object. The device must be connected prior to opening a serial port.
[in]aPortPvDeviceSerial enumeration value representing the device's serial port to open.
Returns
Includes:
PvResult PvDeviceSerialPort::Read ( uint8_t *  aBuffer,
uint32_t  aBufferSize,
uint32_t &  aBytesRead,
uint32_t  aTimeout = 0 
)

Reads from the serial port.

This method reads all bytes currently present in the serial port's receive queue. If no data is present when the function is called, we wait for aTimeout ms before failing on a timeout.

Parameters
[in]aBufferPointer to the buffer where the received bytes are written to.
[in]aBufferSizeSize of the buffer or maximum number of bytes that are read from the serial port.
[out]aBytesReadNumber of bytes read from the serial port.
[in]aTimeoutTime to wait for new bytes, in ms.
Returns
Includes:
PvResult PvDeviceSerialPort::RegisterEchoSink ( PvDeviceSerialPortEchoSink aSink)
static

Registers an echo sink for all device serial communication in the process.

Parameters
[in]aSinkpointer to an object of a class inheriting PvDeviceSerialPortEchoSink.
Returns
Includes:
PvResult PvDeviceSerialPort::SetRxBufferSize ( uint32_t  aSize)

Sets the capacity of the receive buffer. The receive buffer needs to be big enough to buffer all incoming bytes before the user calls Read Resizing the receive buffer flushes all data in that buffer.

Parameters
[in]aSizeNew capacity for the receive buffer.
Returns
Includes:
See also
GetRxBufferSize
PvResult PvDeviceSerialPort::UnregisterEchoSink ( PvDeviceSerialPortEchoSink aSink)
static

Unregisters an echo sink for all device serial communication in the process.

Parameters
[in]aSinkpointer to the object of a class inheriting PvDeviceSerialPortEchoSink to unregister.
Returns
Includes:
PvResult PvDeviceSerialPort::Write ( const uint8_t *  aBuffer,
uint32_t  aSize,
uint32_t &  aBytesWritten 
)

Writes data to the serial port.

Parameters
[in]aBufferPointer to the buffer containing the bytes to write on the serial port.
[in]aSizeNumber of bytes contained in the buffer of data to write on the serial port.
[out]aBytesWrittenNumber of bytes successfully written on the serial port.
Returns
Includes:

The documentation for this class was generated from the following files:

Copyright (c) 2002-2021 Pleora Technologies Inc.
www.pleora.com