Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of mDot_AT_firmware by
ATSerial Class Reference
This class provides a buffered wrapper to the mbed::UnbufferedSerial class. More...
#include <ATSerial.h>
Public Member Functions | |
| ATSerial (PinName txd, PinName rxd, PinName rts=NC, PinName cts=NC, int baud=AT_SERIAL_DEFAULT_BAUD_RATE) | |
| Creates a new ATSerial object that can be used to talk to an mbed serial port through internal SW buffers. | |
| virtual | ~ATSerial () |
| Destructs an ATSerial object and frees all related resources, including internal buffers. | |
| void | baud (int baudrate) |
| This method is used to the set the baud rate of the serial port. | |
| void | format (int bits=8, mbed::SerialBase::Parity parity=mbed::SerialBase::None, int stop_bits=1) |
| This method sets the transmission format used by the serial port. | |
| bool | readable () |
| Check if bytes are available to read. | |
| bool | writeable () |
| Check if bytes can be written. | |
| void | rxClear () |
| Clear the receive buffer. | |
| void | txClear () |
| Clear the transmist buffer. | |
| bool | escaped () |
| Check for escape sequence detected on serial input. | |
| void | escapeChar (char esc) |
| Set escape character. | |
| char | escapeChar () |
| Get the escape character. | |
| void | clearEscaped () |
| Clear escaped state. | |
| bool | read (char &c) |
| Read a byte from receive buffer. | |
| int | read (char *buffer, size_t length) |
| Read bytes from the receive buffer. | |
| int | write (const char *buffer, size_t length) |
| Write bytes from to transmit buffer. | |
| int | writef (const char *format,...) |
| Write formatted string to transmit buffer. | |
Detailed Description
This class provides a buffered wrapper to the mbed::UnbufferedSerial class.
Looks for an escape sequence within received byte stream.
Definition at line 17 of file ATSerial.h.
Constructor & Destructor Documentation
| ATSerial | ( | PinName | txd, |
| PinName | rxd, | ||
| PinName | rts = NC, |
||
| PinName | cts = NC, |
||
| int | baud = AT_SERIAL_DEFAULT_BAUD_RATE |
||
| ) |
Creates a new ATSerial object that can be used to talk to an mbed serial port through internal SW buffers.
Providing RTS and CTS will enable flow control.
- Parameters:
-
txd the transmit data pin on the desired mbed Serial interface. rxd the receive data pin on the desired mbed Serial interface. rts the request-to-send pin on the desired mbed Serial interface. cts the clear-to-send pin on the desired mbed Serial interface. baud The initial baudrate
Definition at line 9 of file ATSerial.cpp.
| ~ATSerial | ( | ) | [virtual] |
Destructs an ATSerial object and frees all related resources, including internal buffers.
Definition at line 38 of file ATSerial.cpp.
Member Function Documentation
| void baud | ( | int | baudrate ) |
This method is used to the set the baud rate of the serial port.
- Parameters:
-
baudrate the baudrate in bps as an int. The default is 9600 bps.
Definition at line 42 of file ATSerial.cpp.
| void clearEscaped | ( | ) |
Clear escaped state.
Definition at line 117 of file ATSerial.cpp.
| void escapeChar | ( | char | esc ) |
Set escape character.
Definition at line 263 of file ATSerial.cpp.
| char escapeChar | ( | ) |
Get the escape character.
Definition at line 267 of file ATSerial.cpp.
| bool escaped | ( | ) |
Check for escape sequence detected on serial input.
- Returns:
- true if escape sequence was seen
Definition at line 94 of file ATSerial.cpp.
| void format | ( | int | bits = 8, |
| mbed::SerialBase::Parity | parity = mbed::SerialBase::None, |
||
| int | stop_bits = 1 |
||
| ) |
This method sets the transmission format used by the serial port.
- Parameters:
-
bits the number of bits in a word (5-8; default = 8) parity the parity used (SerialBase::None, SerialBase::Odd, SerialBase::Even, SerialBase::Forced1, SerialBase::Forced0; default = SerialBase::None) stop the number of stop bits (1 or 2; default = 1)
| bool read | ( | char & | c ) |
Read a byte from receive buffer.
- Parameters:
-
[out] c Storage for read character
- Returns:
- True if a character was read
Definition at line 124 of file ATSerial.cpp.
| int read | ( | char * | buffer, |
| size_t | length | ||
| ) |
Read bytes from the receive buffer.
- Parameters:
-
[out] buffer Allocated memory to store read bytes length Size of buffer in bytes
- Returns:
- Number of bytes read
Definition at line 162 of file ATSerial.cpp.
| bool readable | ( | ) |
Check if bytes are available to read.
- Returns:
- True if receive buffer is not empty.
Definition at line 71 of file ATSerial.cpp.
| void rxClear | ( | ) |
Clear the receive buffer.
Definition at line 79 of file ATSerial.cpp.
| void txClear | ( | ) |
Clear the transmist buffer.
Definition at line 88 of file ATSerial.cpp.
| int write | ( | const char * | buffer, |
| size_t | length | ||
| ) |
Write bytes from to transmit buffer.
- Parameters:
-
buffer Bytes to write length Size of buffer in bytes
- Returns:
- Number of bytes written
Definition at line 128 of file ATSerial.cpp.
| bool writeable | ( | ) |
Check if bytes can be written.
- Returns:
- True if transmit buffer is not full.
Definition at line 75 of file ATSerial.cpp.
| int writef | ( | const char * | format, |
| ... | |||
| ) |
Write formatted string to transmit buffer.
- Parameters:
-
format Format string ... Items to format
- Returns:
- Number of bytes written
Definition at line 150 of file ATSerial.cpp.
Generated on Wed Jan 15 2025 16:10:47 by
1.7.2


