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... | |
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.
To use a serial port:
To check if a device supports a specific serial port:
For a simple example illustrating how to use PvDeviceSerialPort, refer to the sample entitled DeviceSerialPort.
PvResult PvDeviceSerialPort::Close | ( | ) |
Closes the serial port.
PvResult PvDeviceSerialPort::FlushRxBuffer | ( | ) |
Empties the read buffer.
uint64_t PvDeviceSerialPort::GetBytesReceived | ( | ) | const |
Returns how many bytes were received from the serial port.
uint64_t PvDeviceSerialPort::GetBytesSent | ( | ) | const |
Returns how many bytes were sent through the serial port.
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.
[out] | aSize | Current capacity of the receive buffer. |
PvResult PvDeviceSerialPort::GetRxBytesReady | ( | uint32_t & | aBytes | ) |
Returns the number of bytes in the read buffer.
[out] | aBytes | Number of bytes currently queued in the receive buffer. |
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.
[out] | aWritten | How many bytes have been written up to now. |
[out] | aTotal | Total number of bytes to write. |
bool PvDeviceSerialPort::IsOpened | ( | ) |
Returns true if the serial port is opened.
|
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.
[in] | aDevice | Pointer to a PvDevice object. The device must be connected. |
[in] | aPort | PvDeviceSerial enumeration value representing the device's serial port. |
PvResult PvDeviceSerialPort::NotifyReadComplete | ( | ) |
Method used to trigger a OnReadComplete event to PvDeviceSerialPortEchoSink subscribers.
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.
[in] | aDevice | Pointer to a PvDevice object. The device must be connected prior to opening a serial port. |
[in] | aPort | PvDeviceSerial enumeration value representing the device's serial port to open. |
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.
[in] | aBuffer | Pointer to the buffer where the received bytes are written to. |
[in] | aBufferSize | Size of the buffer or maximum number of bytes that are read from the serial port. |
[out] | aBytesRead | Number of bytes read from the serial port. |
[in] | aTimeout | Time to wait for new bytes, in ms. |
|
static |
Registers an echo sink for all device serial communication in the process.
[in] | aSink | pointer to an object of a class inheriting PvDeviceSerialPortEchoSink. |
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.
[in] | aSize | New capacity for the receive buffer. |
|
static |
Unregisters an echo sink for all device serial communication in the process.
[in] | aSink | pointer to the object of a class inheriting PvDeviceSerialPortEchoSink to unregister. |
PvResult PvDeviceSerialPort::Write | ( | const uint8_t * | aBuffer, |
uint32_t | aSize, | ||
uint32_t & | aBytesWritten | ||
) |
Writes data to the serial port.
[in] | aBuffer | Pointer to the buffer containing the bytes to write on the serial port. |
[in] | aSize | Number of bytes contained in the buffer of data to write on the serial port. |
[out] | aBytesWritten | Number of bytes successfully written on the serial port. |
Copyright (c) 2002-2021 Pleora Technologies Inc.
www.pleora.com