Sming Framework API
Sming - Open Source framework for high efficiency WiFi SoC ESP8266 native development with C++ language.
Hardware serial

Access serial UART 0. More...

Functions

 HardwareSerial::HardwareSerial (const int uartPort)
 
void HardwareSerial::begin (const uint32_t baud=9600)
 Initialise the serial port. More...
 
int HardwareSerial::available ()
 Get quantity characters available from serial input. More...
 
int HardwareSerial::read ()
 Read a character from serial port. More...
 
int HardwareSerial::readMemoryBlock (char *buf, int max_len)
 Read a block of characters from serial port. More...
 
int HardwareSerial::peek ()
 Read a character from serial port without removing from input buffer. More...
 
void HardwareSerial::flush ()
 Clear the serial port receive buffer. More...
 
size_t HardwareSerial::write (uint8_t oneChar)
 write a character to serial port More...
 
void HardwareSerial::systemDebugOutput (bool enabled)
 Configure serial port for system debug output. More...
 
void HardwareSerial::commandProcessing (bool reqEnable)
 Configure serial port for command processing. More...
 
void HardwareSerial::setCallback (StreamDataReceivedDelegate reqCallback, bool useSerialRxBuffer=true)
 Set handler for received data. More...
 
void HardwareSerial::resetCallback ()
 Remove handler for received data.
 
static void IRAM_ATTR HardwareSerial::uart0_rx_intr_handler (void *para)
 Interrupt handler for UART0 receive events. More...
 
static void HardwareSerial::delegateTask (os_event_t *inputEvent)
 Trigger task for input event. More...
 

Detailed Description

Access serial UART 0.

Create instance of a hardware serial port object.

Parameters
uartPortUART number [0 | 1]
Note
A global instance of UART 0 is already defined as Serial

Function Documentation

int HardwareSerial::available ( )

Get quantity characters available from serial input.

Return values
intQuantity of characters in receive buffer
void HardwareSerial::begin ( const uint32_t  baud = 9600)

Initialise the serial port.

Parameters
baudBAUD rate of the serial port (Default: 9600)
void HardwareSerial::commandProcessing ( bool  reqEnable)

Configure serial port for command processing.

Parameters
reqEnableTrue to enable command processing
Note
Command processing provides a CLI to the system
See also
commandHandler
static void HardwareSerial::delegateTask ( os_event_t *  inputEvent)
static

Trigger task for input event.

Parameters
inputEventThe event to use for trigger
Todo:
Should HardwareSerial::delgateTask be private?
void HardwareSerial::flush ( )

Clear the serial port receive buffer.

Note
All received data is removed from the serial port buffer
Warning
This function is not implemented!!!
Todo:
Implement Serial::flush()
int HardwareSerial::peek ( )

Read a character from serial port without removing from input buffer.

Return values
intCharacter read from serial port or -1 if buffer empty
Note
The character remains in serial port input buffer
int HardwareSerial::read ( )

Read a character from serial port.

Return values
intCharacter read from serial port or -1 if buffer empty
Note
The character is removed from the serial port input buffer
int HardwareSerial::readMemoryBlock ( char *  buf,
int  max_len 
)

Read a block of characters from serial port.

Parameters
bufPointer to buffer to hold received data
max_lenMaximum quantity of characters to read
Return values
intQuantity of characters read
void HardwareSerial::setCallback ( StreamDataReceivedDelegate  reqCallback,
bool  useSerialRxBuffer = true 
)

Set handler for received data.

Parameters
reqCallbackFunction to handle received data
useSerialRxBufferTrue to use the built-in serial receive buffer
void HardwareSerial::systemDebugOutput ( bool  enabled)

Configure serial port for system debug output.

Parameters
enabledTrue to enable this port for system debug output
Note
If enabled, port will issue system debug messages
static void IRAM_ATTR HardwareSerial::uart0_rx_intr_handler ( void *  para)
static

Interrupt handler for UART0 receive events.

Todo:
Should HardwareSerial::uart0_rx_intr_handler be private?
size_t HardwareSerial::write ( uint8_t  oneChar)

write a character to serial port

Parameters
oneCharCharacter to write to the serial port
Return values
size_tQuantity of characters written (always 1)