Class PvDeviceSerialPort
Provides access the a serial port on a Pleora GigE Vision or USB3 Vision device.
Implements
Inherited Members
Namespace: eBUSDotNetReceive
Assembly: eBUSDotNetReceive.dll
Syntax
public class PvDeviceSerialPort : IDisposable
Remarks
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.
<h2>How to use this class</h2>
<b>To use a serial port:</b>
- Connect to a device using any of the PvDevice::Connect methods.
- Open a serial port to the device using PvDeviceSerialPort::Open.
- Write to the serial port using PvSerialPort::Write.
- Read from the serial port using PvSerialPort::Read.
- Finally close the serial port using PvDeviceSerialPort::Close.
<b>To check if a device supports a specific serial port:</b>
- Connect to a device using any of the PvDevice::Connect methods.
- Use the PvDeviceSerialPort::IsSupported static method.
For a simple example illustrating how to use PvDeviceSerialPort, refer to the sample entitled DeviceSerialPort.
Constructors
View SourcePvDeviceSerialPort()
Constructor.
Declaration
public PvDeviceSerialPort()
Fields
View SourceswigCMemOwn
Determines who is responsible for deleting the underlying C++ object.
Declaration
protected bool swigCMemOwn
Field Value
| Type | Description |
|---|---|
| bool |
Properties
View SourceBytesReceived
Gets the total number of bytes received through the serial port.
Declaration
public ulong BytesReceived { get; }
Property Value
| Type | Description |
|---|---|
| ulong |
BytesSent
Gets the total number of bytes sent through the serial port.
Declaration
public ulong BytesSent { get; }
Property Value
| Type | Description |
|---|---|
| ulong |
IsOpened
Gets whether the serial port is currently opened.
Declaration
public bool IsOpened { get; }
Property Value
| Type | Description |
|---|---|
| bool |
Methods
View SourceClose()
Closes the serial port.
Declaration
public PvResult Close()
Returns
| Type | Description |
|---|---|
| PvResult | Includes:
|
Dispose()
Dispose.
Declaration
public void Dispose()
Dispose(bool)
Dispose
Declaration
protected virtual void Dispose(bool disposing)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | disposing |
~PvDeviceSerialPort()
Destructor.
Declaration
protected ~PvDeviceSerialPort()
FlushRxBuffer()
Empties the read buffer.
Declaration
public PvResult FlushRxBuffer()
Returns
| Type | Description |
|---|---|
| PvResult | Includes:
|
GetRxBufferSize(out uint)
Returns the current capacity of the receive buffer.
Declaration
public PvResult GetRxBufferSize(out uint aSize)
Parameters
| Type | Name | Description |
|---|---|---|
| uint | aSize | Current capacity of the receive buffer. |
Returns
| Type | Description |
|---|---|
| PvResult | Includes:
|
GetRxBytesReady(out uint)
Returns the number of bytes in the read buffer.
Declaration
public PvResult GetRxBytesReady(out uint aBytes)
Parameters
| Type | Name | Description |
|---|---|---|
| uint | aBytes | Number of bytes currently queued in the receive buffer. |
Returns
| Type | Description |
|---|---|
| PvResult | Includes:
|
GetWriteProgress(out uint, out uint)
Gets the progress of an ongoing write operation.
Declaration
public PvResult GetWriteProgress(out uint aWritten, out uint aTotal)
Parameters
| Type | Name | Description |
|---|---|---|
| uint | aWritten | How many bytes have been written up to now. |
| uint | aTotal | Total number of bytes to write. |
Returns
| Type | Description |
|---|---|
| PvResult | Includes:
|
IsSupported(IPvDeviceAdapterSwigInterface, PvDeviceSerial)
Tests if a specific serial port is supported on a device.
Declaration
public static bool IsSupported(IPvDeviceAdapterSwigInterface aDevice, PvDeviceSerial aPort)
Parameters
| Type | Name | Description |
|---|---|---|
| IPvDeviceAdapterSwigInterface | aDevice | Pointer to a #PvDevice object. The device must be connected. |
| PvDeviceSerial | aPort | #PvDeviceSerial enumeration value representing the device's serial port. |
Returns
| Type | Description |
|---|---|
| bool | True if supported. |
NotifyReadComplete()
Method used to trigger a OnReadComplete event to PvDeviceSerialPortEchoSink subscribers.
Declaration
public PvResult NotifyReadComplete()
Returns
| Type | Description |
|---|---|
| PvResult | Includes:
|
Open(IPvDeviceAdapterSwigInterface, PvDeviceSerial)
Opens the serial port.
Declaration
public PvResult Open(IPvDeviceAdapterSwigInterface aDevice, PvDeviceSerial aPort)
Parameters
| Type | Name | Description |
|---|---|---|
| IPvDeviceAdapterSwigInterface | aDevice | Pointer to a #PvDevice object. The device must be connected prior to opening a serial port. |
| PvDeviceSerial | aPort | #PvDeviceSerial enumeration value representing the device's serial port to open. |
Returns
| Type | Description |
|---|---|
| PvResult | Includes:
|
Read(byte*, uint, out uint)
Reads from the serial port.
Declaration
public PvResult Read(byte* aBuffer, uint aBufferSize, out uint aBytesRead)
Parameters
| Type | Name | Description |
|---|---|---|
| byte* | aBuffer | Pointer to the buffer where the received bytes are written to. |
| uint | aBufferSize | Size of the buffer or maximum number of bytes that are read from the serial port. |
| uint | aBytesRead | Number of bytes read from the serial port. |
Returns
| Type | Description |
|---|---|
| PvResult | Includes:
|
Read(byte*, uint, out uint, uint)
Reads from the serial port.
Declaration
public PvResult Read(byte* aBuffer, uint aBufferSize, out uint aBytesRead, uint aTimeout)
Parameters
| Type | Name | Description |
|---|---|---|
| byte* | aBuffer | Pointer to the buffer where the received bytes are written to. |
| uint | aBufferSize | Size of the buffer or maximum number of bytes that are read from the serial port. |
| uint | aBytesRead | Number of bytes read from the serial port. |
| uint | aTimeout | Time to wait for new bytes, in ms. |
Returns
| Type | Description |
|---|---|
| PvResult | Includes:
|
RegisterEchoSink(PvDeviceSerialPortEchoSink)
Registers an echo sink for all device serial communication in the process.
Declaration
public static PvResult RegisterEchoSink(PvDeviceSerialPortEchoSink aSink)
Parameters
| Type | Name | Description |
|---|---|---|
| PvDeviceSerialPortEchoSink | aSink | pointer to an object of a class inheriting PvDeviceSerialPortEchoSink. |
Returns
| Type | Description |
|---|---|
| PvResult | Includes:
|
ResetStatistics()
Resets the port statistics.
Declaration
public void ResetStatistics()
SetRxBufferSize(uint)
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.
Declaration
public PvResult SetRxBufferSize(uint aSize)
Parameters
| Type | Name | Description |
|---|---|---|
| uint | aSize | New capacity for the receive buffer. |
Returns
| Type | Description |
|---|---|
| PvResult | Includes:
|
See Also
UnregisterEchoSink(PvDeviceSerialPortEchoSink)
Unregisters an echo sink for all device serial communication in the process.
Declaration
public static PvResult UnregisterEchoSink(PvDeviceSerialPortEchoSink aSink)
Parameters
| Type | Name | Description |
|---|---|---|
| PvDeviceSerialPortEchoSink | aSink | pointer to the object of a class inheriting PvDeviceSerialPortEchoSink to unregister. |
Returns
| Type | Description |
|---|---|
| PvResult | Includes:
|
Write(byte[], uint, out uint)
Writes data to the serial port.
Declaration
public PvResult Write(byte[] aBuffer, uint aSize, out uint aBytesWritten)
Parameters
| Type | Name | Description |
|---|---|---|
| byte[] | aBuffer | Pointer to the buffer containing the bytes to write on the serial port. |
| uint | aSize | Number of bytes contained in the buffer of data to write on the serial port. |
| uint | aBytesWritten | Number of bytes successfully written on the serial port. |
Returns
| Type | Description |
|---|---|
| PvResult | Includes:
|