Skip to content

Serial: Deprecate the class and promote UnbufferedSerial instead #12121

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 19, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 24 additions & 6 deletions drivers/Serial.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ namespace mbed {
* @{
*/

/** A serial port (UART) for communication with other serial devices
/** @deprecated
* A serial port (UART) for communication with other serial devices
*
* Can be used for Full Duplex communication, or Simplex by specifying
* one pin as NC (Not Connected)
Expand All @@ -53,7 +54,11 @@ namespace mbed {
* }
* @endcode
*/
class Serial : public SerialBase, public Stream, private NonCopyable<Serial> {
class
MBED_DEPRECATED_SINCE(
"mbed-os-6.0.0",
"Use printf and puts instead to access the console, BufferedSerial for blocking applications or UnbufferedSerial if bypassing locks in IRQ or short of RAM."
) Serial : public SerialBase, public Stream, private NonCopyable<Serial> {

public:
#if DEVICE_SERIAL_ASYNCH
Expand All @@ -67,7 +72,8 @@ class Serial : public SerialBase, public Stream, private NonCopyable<Serial> {
using SerialBase::enable_input;
using SerialBase::enable_output;

/** Create a Serial port, connected to the specified transmit and receive pins
/** @deprecated
* Create a Serial port, connected to the specified transmit and receive pins
*
* @param tx Transmit pin
* @param rx Receive pin
Expand All @@ -77,9 +83,11 @@ class Serial : public SerialBase, public Stream, private NonCopyable<Serial> {
* @note
* Either tx or rx may be specified as NC (Not Connected) if unused
*/
MBED_DEPRECATED("The class has been deprecated and will be removed in the future.")
Serial(PinName tx, PinName rx, const char *name = NULL, int baud = MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE);

/** Create a Serial port, connected to the specified transmit and receive pins
/** @deprecated
* Create a Serial port, connected to the specified transmit and receive pins
*
* @param static_pinmap reference to structure which holds static pinmap.
* @param name The name of the stream associated with this serial port (optional)
Expand All @@ -88,10 +96,13 @@ class Serial : public SerialBase, public Stream, private NonCopyable<Serial> {
* @note
* Either tx or rx may be specified as NC (Not Connected) if unused
*/
MBED_DEPRECATED("The class has been deprecated and will be removed in the future.")
Serial(const serial_pinmap_t &static_pinmap, const char *name = NULL, int baud = MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE);
MBED_DEPRECATED("The class has been deprecated and will be removed in the future.")
Serial(const serial_pinmap_t &&, const char * = NULL, int = MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE) = delete; // prevent passing of temporary objects

/** Create a Serial port, connected to the specified transmit and receive pins, with the specified baud
/** @deprecated
* Create a Serial port, connected to the specified transmit and receive pins, with the specified baud
*
* @param tx Transmit pin
* @param rx Receive pin
Expand All @@ -100,31 +111,38 @@ class Serial : public SerialBase, public Stream, private NonCopyable<Serial> {
* @note
* Either tx or rx may be specified as NC (Not Connected) if unused
*/
MBED_DEPRECATED("The class has been deprecated and will be removed in the future.")
Serial(PinName tx, PinName rx, int baud);

/** Create a Serial port, connected to the specified transmit and receive pins, with the specified baud
/** @deprecated
* Create a Serial port, connected to the specified transmit and receive pins, with the specified baud
*
* @param static_pinmap reference to structure which holds static pinmap.
* @param baud The baud rate of the serial port
*
* @note
* Either tx or rx may be specified as NC (Not Connected) if unused
*/
MBED_DEPRECATED("The class has been deprecated and will be removed in the future.")
Serial(const serial_pinmap_t &static_pinmap, int baud);
MBED_DEPRECATED("The class has been deprecated and will be removed in the future.")
Serial(const serial_pinmap_t &&, int) = delete; // prevent passing of temporary objects

/* Stream gives us a FileHandle with non-functional poll()/readable()/writable. Pass through
* the calls from the SerialBase instead for backwards compatibility. This problem is
* part of why Stream and Serial should be deprecated.
*/
MBED_DEPRECATED("The class has been deprecated and will be removed in the future.")
bool readable()
{
return SerialBase::readable();
}
MBED_DEPRECATED("The class has been deprecated and will be removed in the future.")
bool writable()
{
return SerialBase::writeable();
}
MBED_DEPRECATED("The class has been deprecated and will be removed in the future.")
bool writeable()
{
return SerialBase::writeable();
Expand Down