VisionBox Interface Library  1.7.5.0 (2021-12-10)
VIB::Rs232 Class Reference
+ Inheritance diagram for VIB::Rs232:

Detailed Description

This class represents the RS-232 interface which allows sending and receiving data over a RS-232 port.

Public Member Functions

bool ConfigureBaudRate (const unsigned int BaudRate)
 Configures the baud rate. More...
 
bool GetNumberOfBytesAvailable (unsigned int &NumberOfBytesAvailable)
 Returns the number of valid characters within the receive buffer. More...
 
bool ReadNByte (const unsigned int BytesToRead, unsigned int &BytesIn, unsigned char *pData, const unsigned int msTimeout)
 Reads the specified number of characters. More...
 
 Rs232 ()
 Default constructor for the device object More...
 
bool WriteNByte (const unsigned int BytesToWrite, const unsigned char *pData)
 Sends the given number of bytes. More...
 
- Public Member Functions inherited from VIB::iDevice
bool Close ()
 Closes a device More...
 
 iDevice (const iDevice &device)
 The copy constructor makes a copy of the existing device object More...
 
bool isOpen (bool &state)
 Returns the open state of a device object More...
 
bool Open (unsigned int Index=0)
 Opens a device More...
 
iDeviceoperator= (const iDevice &device)
 The assignment operator makes a copy of the existing device object More...
 
virtual ~iDevice ()
 Deletes the device object More...
 

Constructor & Destructor Documentation

◆ Rs232()

VIB::Rs232::Rs232 ( )

Default constructor for the device object

The device must be opened with Open() before it can be used.

Member Function Documentation

◆ ConfigureBaudRate()

bool VIB::Rs232::ConfigureBaudRate ( const unsigned int  BaudRate)

Configures the baud rate.

Must be called before the user can send or receive data.

Parameters
BaudRatethe desired speed, from 9600 to 921600
Returns
true for success, use VIBSystem::GetLastErrorString() for an error description

◆ GetNumberOfBytesAvailable()

bool VIB::Rs232::GetNumberOfBytesAvailable ( unsigned int &  NumberOfBytesAvailable)

Returns the number of valid characters within the receive buffer.

Parameters
NumberOfBytesAvailableNumber of bytes that can be read with ReadNByte() without blocking
Returns
true for success, use VIBSystem::GetLastErrorString() for an error description

◆ ReadNByte()

bool VIB::Rs232::ReadNByte ( const unsigned int  BytesToRead,
unsigned int &  BytesIn,
unsigned char *  pData,
const unsigned int  msTimeout 
)

Reads the specified number of characters.

The function waits until all the desired bytes are received, or until the specified timeout expires. The function returns successfully, if at least one byte was received.

Parameters
BytesToReadNumber of bytes to copy to pData buffer
BytesInNumber of valid bytes returned
pDataValid pointer to buffer for storing the received bytes
msTimeoutTimeOut in milliseconds, 0 ... INFINITE
Returns
true for success, use VIBSystem::GetLastErrorString() for an error description

◆ WriteNByte()

bool VIB::Rs232::WriteNByte ( const unsigned int  BytesToWrite,
const unsigned char *  pData 
)

Sends the given number of bytes.

The functions doesn't wait not for completion of the transmit operation.

Parameters
BytesToWriteNumber of bytes to send
pDataPointer to the data
Returns
true for success, use VIBSystem::GetLastErrorString() for an error description