ClearCore Library
List of all members | Public Types | Public Member Functions
ClearCore::ISerial Class Referenceabstract

Detailed Description

Base class for interacting with all ClearCore serial.

This virtual class defines the common functionality for a serial object.

It provides a generic interface that all serial objects have. This includes

Base class for interacting with all ClearCore serial. More...

#include <ISerial.h>

+ Inheritance diagram for ClearCore::ISerial:

Public Types

enum  _Parities { PARITY_E = 0, PARITY_O, PARITY_N }
 
typedef enum ClearCore::ISerial::_Parities Parities
 

Public Member Functions

virtual void Flush ()=0
 
virtual void FlushInput ()=0
 
virtual void PortOpen ()=0
 
virtual void PortClose ()=0
 
virtual bool Speed (uint32_t bitsPerSecond)=0
 Change the baud rate for the port. More...
 
virtual uint32_t Speed ()=0
 Gets the baud rate of the port. More...
 
virtual int16_t CharGet ()=0
 Attempt to read the next character from serial channel. More...
 
virtual int16_t CharPeek ()=0
 Attempt to get the next character from the serial channel without pulling the character out of the buffer. More...
 
virtual bool SendChar (uint8_t charToSend)=0
 Send an ascii character on the serial channel. More...
 
bool SendLine ()
 Send carriage return and newline characters. More...
 
bool Send (const char *buffer, size_t bufferSize)
 Send the array of characters out the port. More...
 
bool SendLine (const char *buffer, size_t bufferSize)
 Send the array of characters out the port. Terminate the line with carriage return and newline characters. More...
 
bool Send (const char *nullTermStr)
 Send a string of characters out the port. More...
 
bool SendLine (const char *nullTermStr)
 Send a string of characters out the port. Terminate the line with carriage return and newline characters. More...
 
bool Send (char theChar)
 Send a character to be printed to the serial port. More...
 
bool SendLine (char theChar)
 Send a character to be printed to the serial port. Terminate the line with carriage return and newline characters. More...
 
bool Send (double number, uint8_t precision=2)
 Send a floating point number to the serial port. More...
 
bool SendLine (double number, uint8_t precision=2)
 Send a floating point number to the serial port. Terminate the line with carriage return and newline characters. More...
 
bool Send (int8_t number, uint8_t radix=10)
 Send an 8-bit signed number to be printed to the serial port. More...
 
bool SendLine (int8_t number, uint8_t radix=10)
 Send an 8-bit signed number to be printed to the serial port. Terminate the line with carriage return and newline characters. More...
 
bool Send (uint8_t number, uint8_t radix=10)
 Send an 8-bit unsigned number to be printed to the serial port. More...
 
bool SendLine (uint8_t number, uint8_t radix=10)
 Send an 8-bit unsigned number to be printed to the serial port. Terminate the line with carriage return and newline characters. More...
 
bool Send (int16_t number, uint8_t radix=10)
 Send a 16-bit signed number to be printed to the serial port. More...
 
bool SendLine (int16_t number, uint8_t radix=10)
 Send a 16-bit signed number to be printed to the serial port. Terminate the line with carriage return and newline characters. More...
 
bool Send (uint16_t number, uint8_t radix=10)
 Send a 16-bit unsigned number to be printed to the serial port. More...
 
bool SendLine (uint16_t number, uint8_t radix=10)
 Send a 16-bit unsigned number to be printed to the serial port. Terminate the line with carriage return and newline characters. More...
 
bool Send (int32_t number, uint8_t radix=10)
 Send a 32-bit signed number to be printed to the serial port. More...
 
bool SendLine (int32_t number, uint8_t radix=10)
 Send a 32-bit signed number to be printed to the serial port. Terminate the line with carriage return and newline characters. More...
 
bool Send (uint32_t number, uint8_t radix=10)
 Send a 32-bit unsigned number to be printed to the serial port. More...
 
bool SendLine (uint32_t number, uint8_t radix=10)
 Send a 32-bit unsigned number to be printed to the serial port. Terminate the line with carriage return and newline characters. More...
 
bool Send (int number, uint8_t radix=10)
 Send an integer to be printed to the serial port. More...
 
bool SendLine (int number, uint8_t radix=10)
 Send an integer to be printed to the serial port. More...
 
virtual int32_t AvailableForRead ()=0
 
virtual int32_t AvailableForWrite ()=0
 Determines the number of characters available in the transmit buffer. More...
 
virtual void WaitForTransmitIdle ()=0
 
virtual bool PortIsOpen ()=0
 Return whether or not the port is open. More...
 
virtual operator bool ()=0
 
virtual bool Parity (Parities newParity)=0
 Set UART transmission parity format. More...
 
virtual Parities Parity ()=0
 Return current port UART transmission format. More...
 
virtual bool StopBits (uint8_t bits)=0
 
virtual bool CharSize (uint8_t size)=0
 Change the number of bits in a character. More...
 

Member Typedef Documentation

Different types of transmission formats

Member Enumeration Documentation

Different types of transmission formats

Enumerator
PARITY_E 

Even Parity.

PARITY_O 

Odd Parity.

PARITY_N 

No Parity.

Member Function Documentation

virtual int32_t ClearCore::ISerial::AvailableForRead ( )
pure virtual

Returns number of characters waiting in the receive buffer.

Implemented in ClearCore::SerialBase, and ClearCore::SerialUsb.

virtual int32_t ClearCore::ISerial::AvailableForWrite ( )
pure virtual

Determines the number of characters available in the transmit buffer.

// There are less than 10 free characters in COM-0's transmit buffer
}
Returns
Returns number of free characters in transmit buffer

Implemented in ClearCore::SerialBase, and ClearCore::SerialUsb.

virtual int16_t ClearCore::ISerial::CharGet ( )
pure virtual

Attempt to read the next character from serial channel.

Returns
Returns the first character in the serial buffer, or SerialBase::EOB if no data are available. If a character is found, it will be consumed and removed from the serial buffer.

Implemented in ClearCore::SerialBase, and ClearCore::SerialUsb.

virtual int16_t ClearCore::ISerial::CharPeek ( )
pure virtual

Attempt to get the next character from the serial channel without pulling the character out of the buffer.

Returns
Returns the first character in the serial buffer, or SerialBase::EOB if no data are available. If a character is found, it will not be consumed, and will remain in the serial buffer for reading.

Implemented in ClearCore::SerialBase, and ClearCore::SerialUsb.

virtual bool ClearCore::ISerial::CharSize ( uint8_t  size)
pure virtual

Change the number of bits in a character.

// Setting COM-0's character size was successful
}
Parameters
[in]sizeThe new character size to be set
Note
For UART mode valid settings are: 5,6,7,8,9. For SPI mode valid settings are: 8, 9.

Implemented in ClearCore::SerialBase, and ClearCore::SerialUsb.

virtual void ClearCore::ISerial::Flush ( )
pure virtual

Flush the serial port's transmit buffer

// Flush COM-0's transmit buffer

Implemented in ClearCore::SerialBase, and ClearCore::SerialUsb.

virtual void ClearCore::ISerial::FlushInput ( )
pure virtual

Flush the serial port's receive buffer

// Flush COM-0's receive buffer

Implemented in ClearCore::SerialBase, and ClearCore::SerialUsb.

virtual ClearCore::ISerial::operator bool ( )
pure virtual

Returns whether the serial port is open and the other end is connected.

Implemented in ClearCore::SerialUsb.

virtual bool ClearCore::ISerial::Parity ( Parities  newParity)
pure virtual

Set UART transmission parity format.

// Setting COM-0's parity format to odd was successful
}
Parameters
[in]newParityThe new parity to be set
Returns
Returns true if port accepted the format change request.

Implemented in ClearCore::SerialBase, and ClearCore::SerialUsb.

virtual Parities ClearCore::ISerial::Parity ( )
pure virtual

Return current port UART transmission format.

// COM-0's parity format is set to odd
}
Returns
Returns transmission format enumeration.

Implemented in ClearCore::SerialBase, and ClearCore::SerialUsb.

virtual void ClearCore::ISerial::PortClose ( )
pure virtual

Shut down the port

// Close COM-0's serial port

Implemented in ClearCore::SerialBase, ClearCore::SerialDriver, and ClearCore::SerialUsb.

virtual bool ClearCore::ISerial::PortIsOpen ( )
pure virtual

Return whether or not the port is open.

// COM-0's port is currently open
}
Returns
True if the port is open, and false otherwise.

Implemented in ClearCore::SerialBase, and ClearCore::SerialUsb.

virtual void ClearCore::ISerial::PortOpen ( )
pure virtual

Set up the port to allow operations

// Open COM-0's serial port

Implemented in ClearCore::SerialBase, ClearCore::SerialDriver, and ClearCore::SerialUsb.

bool ClearCore::ISerial::Send ( const char *  buffer,
size_t  bufferSize 
)
inline
bool ClearCore::ISerial::Send ( const char *  nullTermStr)
inline

Send a string of characters out the port.

Parameters
[in]nullTermStrThe string to be sent
Returns
success
bool ClearCore::ISerial::Send ( char  theChar)
inline

Send a character to be printed to the serial port.

Parameters
[in]theCharThe ascii character to be printed.
Returns
success
bool ClearCore::ISerial::Send ( double  number,
uint8_t  precision = 2 
)
inline

Send a floating point number to the serial port.

Parameters
[in]numberThe double precision float value to be printed.
[in]precision(optional) The number of digits to print after the decimal point. Default: 2.
Note
The string representation is capped at 20 characters.
Returns
success
bool ClearCore::ISerial::Send ( int8_t  number,
uint8_t  radix = 10 
)
inline

Send an 8-bit signed number to be printed to the serial port.

Parameters
[in]numberThe value to be printed.
[in]radix(optional) The base in which to display the character representation of number. Default: 10.
Returns
success
bool ClearCore::ISerial::Send ( uint8_t  number,
uint8_t  radix = 10 
)
inline

Send an 8-bit unsigned number to be printed to the serial port.

Parameters
[in]numberThe value to be printed.
[in]radix(optional) The base in which to display the character representation of number. Default: 10.
Returns
success
bool ClearCore::ISerial::Send ( int16_t  number,
uint8_t  radix = 10 
)
inline

Send a 16-bit signed number to be printed to the serial port.

Parameters
[in]numberThe value to be printed.
[in]radix(optional) The base in which to display the character representation of number. Default: 10.
Returns
success
bool ClearCore::ISerial::Send ( uint16_t  number,
uint8_t  radix = 10 
)
inline

Send a 16-bit unsigned number to be printed to the serial port.

Parameters
[in]numberThe value to be printed.
[in]radix(optional) The base in which to display the character representation of number. Default: 10.
Returns
success
bool ClearCore::ISerial::Send ( int32_t  number,
uint8_t  radix = 10 
)
inline

Send a 32-bit signed number to be printed to the serial port.

Parameters
[in]numberThe value to be printed.
[in]radix(optional) The base in which to display the character representation of number. Default: 10.
Returns
success
bool ClearCore::ISerial::Send ( uint32_t  number,
uint8_t  radix = 10 
)
inline

Send a 32-bit unsigned number to be printed to the serial port.

Parameters
[in]numberThe value to be printed.
[in]radix(optional) The base in which to display the character representation of number. Default: 10.
Returns
success
bool ClearCore::ISerial::Send ( int  number,
uint8_t  radix = 10 
)
inline

Send an integer to be printed to the serial port.

Parameters
[in]numberThe integer value to be printed.
[in]radix(optional) The base in which to display the character representation of number. Default: 10.
Returns
success
virtual bool ClearCore::ISerial::SendChar ( uint8_t  charToSend)
pure virtual

Send an ascii character on the serial channel.

Parameters
[in]charToSendThe character to be sent
Returns
success

Implemented in ClearCore::SerialBase, and ClearCore::SerialUsb.

bool ClearCore::ISerial::SendLine ( )
inline
bool ClearCore::ISerial::SendLine ( const char *  buffer,
size_t  bufferSize 
)
inline

Send the array of characters out the port. Terminate the line with carriage return and newline characters.

Parameters
[in]bufferThe array of characters to be sent
[in]bufferSizeThe number of characters to be sent
Returns
success
bool ClearCore::ISerial::SendLine ( const char *  nullTermStr)
inline

Send a string of characters out the port. Terminate the line with carriage return and newline characters.

Parameters
[in]nullTermStrThe string to be sent
Returns
success
bool ClearCore::ISerial::SendLine ( char  theChar)
inline

Send a character to be printed to the serial port. Terminate the line with carriage return and newline characters.

Parameters
[in]theCharThe ascii character to be printed.
Returns
success
bool ClearCore::ISerial::SendLine ( double  number,
uint8_t  precision = 2 
)
inline

Send a floating point number to the serial port. Terminate the line with carriage return and newline characters.

Parameters
[in]numberThe double precision float value to be printed.
[in]precision(optional) The number of digits to print after the decimal point. Default: 2.
Note
The string representation is capped at 20 characters.
Returns
success
bool ClearCore::ISerial::SendLine ( int8_t  number,
uint8_t  radix = 10 
)
inline

Send an 8-bit signed number to be printed to the serial port. Terminate the line with carriage return and newline characters.

Parameters
[in]numberThe value to be printed.
[in]radix(optional) The base in which to display the character representation of number. Default: 10.
Returns
success
bool ClearCore::ISerial::SendLine ( uint8_t  number,
uint8_t  radix = 10 
)
inline

Send an 8-bit unsigned number to be printed to the serial port. Terminate the line with carriage return and newline characters.

Parameters
[in]numberThe value to be printed.
[in]radix(optional) The base in which to display the character representation of number. Default: 10.
Returns
success
bool ClearCore::ISerial::SendLine ( int16_t  number,
uint8_t  radix = 10 
)
inline

Send a 16-bit signed number to be printed to the serial port. Terminate the line with carriage return and newline characters.

Parameters
[in]numberThe value to be printed.
[in]radix(optional) The base in which to display the character representation of number. Default: 10.
Returns
success
bool ClearCore::ISerial::SendLine ( uint16_t  number,
uint8_t  radix = 10 
)
inline

Send a 16-bit unsigned number to be printed to the serial port. Terminate the line with carriage return and newline characters.

Parameters
[in]numberThe value to be printed.
[in]radix(optional) The base in which to display the character representation of number. Default: 10.
Returns
success
bool ClearCore::ISerial::SendLine ( int32_t  number,
uint8_t  radix = 10 
)
inline

Send a 32-bit signed number to be printed to the serial port. Terminate the line with carriage return and newline characters.

Parameters
[in]numberThe value to be printed.
[in]radix(optional) The base in which to display the character representation of number. Default: 10.
Returns
success
bool ClearCore::ISerial::SendLine ( uint32_t  number,
uint8_t  radix = 10 
)
inline

Send a 32-bit unsigned number to be printed to the serial port. Terminate the line with carriage return and newline characters.

Parameters
[in]numberThe value to be printed.
[in]radix(optional) The base in which to display the character representation of number. Default: 10.
Returns
success
bool ClearCore::ISerial::SendLine ( int  number,
uint8_t  radix = 10 
)
inline

Send an integer to be printed to the serial port.

Parameters
[in]numberThe integer value to be printed.
[in]radix(optional) The base in which to display the character representation of number. Default: 10.
Returns
success
virtual bool ClearCore::ISerial::Speed ( uint32_t  bitsPerSecond)
pure virtual
virtual uint32_t ClearCore::ISerial::Speed ( )
pure virtual

Gets the baud rate of the port.

// Saves COM-0's current speed setting
uint32_t serialSpeed = ConnectorCOM1.Speed();
Returns
Returns port speed in bits per second.

Implemented in ClearCore::SerialBase.

virtual bool ClearCore::ISerial::StopBits ( uint8_t  bits)
pure virtual

Change the number of stop bits used in UART communication.

// Setting COM-0's stop bits was successful
}

Implemented in ClearCore::SerialBase, and ClearCore::SerialUsb.

virtual void ClearCore::ISerial::WaitForTransmitIdle ( )
pure virtual

Wait for transmission idle.

Implemented in ClearCore::SerialBase, and ClearCore::SerialUsb.


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