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

Member Typedef Documentation

◆ Parities

Different types of transmission formats

Member Enumeration Documentation

◆ _Parities

Different types of transmission formats

Enumerator
PARITY_E 

Even Parity.

PARITY_O 

Odd Parity.

PARITY_N 

No Parity.

Member Function Documentation

◆ AvailableForRead()

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

Returns number of characters waiting in the receive buffer.

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

◆ AvailableForWrite()

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
}
int32_t AvailableForWrite() override
Determines the number of characters available in the transmit buffer.
SerialDriver ConnectorCOM0
COM-0 connector instance.
Returns
Returns number of free characters in transmit buffer

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

◆ CharGet()

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.

◆ CharPeek()

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.

◆ CharSize()

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
}
bool CharSize(uint8_t size) override
Change the number of bits in a character.
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.

◆ Flush()

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

Flush the serial port's transmit buffer

// Flush COM-0's transmit buffer
void Flush() override

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

◆ FlushInput()

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

Flush the serial port's receive buffer

// Flush COM-0's receive buffer
void FlushInput() override

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

◆ operator bool()

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

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

Implemented in ClearCore::SerialUsb.

◆ Parity() [1/2]

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

Return current port UART transmission format.

// COM-0's parity format is set to odd
}
@ PARITY_O
Odd Parity.
Definition ISerial.h:60
bool Parity(Parities newParity) override
Set UART transmission parity format.
Returns
Returns transmission format enumeration.

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

◆ Parity() [2/2]

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.

◆ PortClose()

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

Shut down the port

// Close COM-0's serial port
void PortClose() override

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

◆ PortIsOpen()

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

Return whether or not the port is open.

// COM-0's port is currently open
}
bool PortIsOpen() override
Return whether or not the port is open.
Returns
True if the port is open, and false otherwise.

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

◆ PortOpen()

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

Set up the port to allow operations

// Open COM-0's serial port
void PortOpen() override

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

◆ Send() [1/11]

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

◆ Send() [2/11]

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

◆ Send() [3/11]

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

◆ Send() [4/11]

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

◆ Send() [5/11]

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

◆ Send() [6/11]

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

◆ Send() [7/11]

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

◆ Send() [8/11]

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

◆ Send() [9/11]

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

◆ Send() [10/11]

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

◆ Send() [11/11]

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

◆ SendChar()

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.

◆ SendLine() [1/12]

bool ClearCore::ISerial::SendLine ( )
inline

◆ SendLine() [2/12]

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

◆ SendLine() [3/12]

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

◆ SendLine() [4/12]

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

◆ SendLine() [5/12]

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

◆ SendLine() [6/12]

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

◆ SendLine() [7/12]

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

◆ SendLine() [8/12]

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

◆ SendLine() [9/12]

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

◆ SendLine() [10/12]

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

◆ SendLine() [11/12]

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

◆ SendLine() [12/12]

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

◆ Speed() [1/2]

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();
bool Speed(uint32_t bitsPerSecond) override
Change the baud rate for the port.
Definition SerialDriver.h:159
SerialDriver ConnectorCOM1
COM-1 connector instance.
Returns
Returns port speed in bits per second.

Implemented in ClearCore::SerialBase.

◆ Speed() [2/2]

virtual bool ClearCore::ISerial::Speed ( uint32_t  bitsPerSecond)
pure virtual

◆ StopBits()

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
}
bool StopBits(uint8_t bits) override

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

◆ WaitForTransmitIdle()

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: