Skip to content

Commit 7d81305

Browse files
committed
Removed MinimalSerial
1 parent 625b4eb commit 7d81305

File tree

3 files changed

+18
-40
lines changed

3 files changed

+18
-40
lines changed
Loading
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<mxfile host="www.draw.io" modified="2019-10-04T11:48:22.101Z" agent="Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.1 Safari/605.1.15" etag="89rnh_Xjw2BzIMUwFD7w" version="12.0.2" type="onedrive" pages="1"><diagram id="IPPSj4dfQhI11Ljdv34q" name="Page-1">5VnbctowEP0aHtPxBVzyWAiQpsm0HZpbXzqKtWBNhUVlEUy+vnItY1tyCiZAnPaF8a7WK+mc1ZFkWm5/Fo84mgdXDANtORaOW+5Zy3G6XVv+Jo5V6ug4VuqYcoJTl507xuQJlDMLWxAMUSlQMEYFmZedPgtD8EXJhzhny3LYhNFyr3M0BcMx9hE1vbcEi0B5be80bzgHMg1U113HSxtmKAtWM4kChNmy4HIHLbfPGRPp0yzuA02wy3BJ3xs+07oeGIdQbPNC+JXffLN+ff98eXLfvUX+CF38PFFZHhFdqAmPgRNEeygCNWyxyrDgbBFiSNJZLbe3DIiA8Rz5SetSki99gZhRadny0Rxe1hdwAXHBpYY7AjYDwVcyRLU6loJO1Y7jKntZYCKDNyiQkMUhRf50nTrHRz4oiGrA5RpwDQmFcxRi+vpwuV7T4OoYcPUWkwlwwGmVNQ4y19kSsvahIOsakBkgQYg/JMomLZ+iKCL+lrgALmmdiUph1p2KSWc+DhQJ8lhWyCokVA9fGJEjyZe1XqddDcyILbgP6q2iom1K5GmJBOJTEEaiP8Ssp707V6cv50pSxFd3Sb2/62TmfbHtLFaLIbVWymo6x21nTxwbiY7Mse3UIjlkIfynq3Ej5Ydmytyc/y2m3La2WVk7MqUnOiBT1/HTxcjt3Vh3w+DGwh7BDxcn9ZZUtW7GRBRkU1r3mU7K51w0E2OjZqa4bT4lN6QO9BVr64eRXfdP+/RgdXDVX9x+6vgfn+xJ78cl+IOBM6y4fFyHD806IOpXkKMeECtBM1XuioRkhmhDEbO9LRHbxy2kErH2c4j1WRixBlzcdDk+5r2tEjHz3lZvJz2YOv9NRpqizlr9t3WWdlVnY7s/sDp7TSqChpCrn3HX28FLD8vHJvf9C8ltOlEbF89bIare96C3R5Stf+O19ySXRqJniJLQoVUhbJ4ERNtXVtZP3XHldZKOYK9VU+/L1Gtv4O1GVaS+4o1b0bYVubG0d5YOaeb/G6Xh+Z9v7uA3</diagram></mxfile>
2+
<mxfile host="www.draw.io" modified="2019-10-30T15:23:45.459Z" agent="Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.2 Safari/605.1.15" etag="Cbni6TBbBp9rgvvEG1H-" version="12.1.8" type="onedrive" pages="1"><diagram id="IPPSj4dfQhI11Ljdv34q" name="Page-1">5Vhtk9IwEP41/XhOSQDho3DAqXejDiriFyc2S5sxNJimR7lff6lN6UtweDnhOuenZjebTfI8u9mdOni4TCaSrII7QYE7yKWJg68dhFqtnqs/qWaTafqokyl8yagxKhRT9gBGadb5MaMQVQyVEFyxVVXpiTAET1V0REqxrpotBK/uuiI+WIqpR7itnTGqgvxe3X4xcQPMD8zWPdTNJpYkNzY3iQJCxbqkwiMHD6UQKhstkyHwFLwcl2zd+C+z24NJCNUhC8JP8utn9/f3D7dX896MeBPy7teV8XJPeGwuPAXJCB+QCMyx1SbHQoo4pJC6cx08WAdMwXRFvHR2rdnXukAtuZZaemgfL98LpIKkpDLHnYBYgpIbbWJmkWugM7GDsJHXJSZyeIMSCbkdMeT7W9cFPnpgIDoCLmzBNWYcbkhI+fPDhbtNg6tjwTWIFwuQQLMoaxxkGB0IWftckPUsyCyQIKRv0pdNSx4nUcS8A3EBWnnrbFRKt+7suHSuk8CJYvfVF3IXEmaHj4LpkxRpXY/TXg3MSMTSA7Oq/KLtc9StOVJE+qAsR3+I2V77dK76T+dKUyQ339J4f9XJxXl57joxyZBJGyM1neM2+kccW44uzHELHUVyKEL4T7NxL+XnZsouzi+LKdyuFSv3RKbqjs7I1N0wnr3veG8fWovBj1vwRiM03tF0fgl/NqsxqLeeF20MdoJm91LHRTckTJUKjZbmeWXR46LMpMLeKpNF2n6KG5I5dTbb9Y731I7DSsEzZ063SUHQEHLrdWebqk8tYJcm9/ULr197k+f5idJi8UMmMy9+a+HRIw==</diagram></mxfile>

docs/design-documents/drivers/serial/serial.md

Lines changed: 17 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,6 @@ The below diagram shows the inheritance hierarchy for the serial classes.
7373

7474
![Serial classes](./diagrams/serial-classes.png)
7575

76-
`MinimalSerial` is an abstract class that extracts basics I/O functionality from `SerialBase` so it can be re-used for a minimal serial console in the retarget code.
77-
7876
# Detailed design
7977

8078
### Detailed design : BufferedSerial
@@ -183,42 +181,6 @@ protected:
183181
};
184182
```
185183

186-
### Detailed design : MinimalSerial
187-
188-
The `MinimalSerial` class is a minimal abstract base class that provides basics I/O functionality. It is not part of the public interface. All other serial classes derive from it.
189-
190-
**API description**
191-
192-
This is the proposed API for the `MinimalSerial` class. Only two methods are provided to output `_base_putc()` and receive `_base_getc()` characters on the UART.
193-
194-
```C
195-
class MinimalSerial : private NonCopyable<MinimalSerial> {
196-
protected:
197-
MinimalSerial(PinName tx, PinName rx, int baud);
198-
virtual ~MinimalSerial();
199-
int _base_getc();
200-
int _base_putc(int c);
201-
};
202-
```
203-
204-
### Detailed design : MinimalConsole
205-
206-
`MinimalConsole` is an internal concrete class that derives from `MinimalSerial` and provides basic console functionality that can be used by the retarget code for resources constrained targets, see [Simplication of retarget code](#simplification-of-retarget-code).
207-
208-
**API description**
209-
210-
```C
211-
class MinimalConsole : public MinimalSerial, private NonCopyable<MinimalConsole> {
212-
public:
213-
MinimalConsole(PinName tx, PinName rx, int baud);
214-
virtual ~MinimalConsole();
215-
int getc();
216-
int putc(int c);
217-
};
218-
```
219-
220-
The constructor provides arguments to create a serial port connected to the specified transmit and receive pins and set to the specified baud rate. If a target has serial support, by default a serial port is used for the console and the pins and settings for the port selection come from target header files and JSON settings.
221-
222184
# Usage scenarios and examples
223185

224186
### Scenario 1 `Printing to stdout`
@@ -249,6 +211,12 @@ UnbufferedSerial serial(RX, TX, 115200);
249211
FILE *out = fdopen(&serial, "w");
250212
fprintf(out, "Hello");
251213
```
214+
alternatively
215+
216+
```C
217+
UnbufferedSerial serial(RX, TX, 115200);
218+
serial.write("Hello", 6);
219+
```
252220
253221
# Other Work
254222
@@ -279,7 +247,17 @@ There are two approaches to achieve a minimal retarget layer. You can:
279247

280248
A minimal console only needs to write a single character at a time. So redefining the default fputc() to directly write to the serial port if the output stream is stdout and bypassing the system I/O functions should achieve higher memory savings. If we take this approach, we will have to rework some error handlers that rely on the POSIX form of `write(STDOUT_FILENO, buf, len)` to do emergency printing.
281249

282-
The second solution keeps the POSIX layer with the main saving coming from dropping the use of `FileHandle` and the file handle table itself. In this case, `write()` would call `MinimalConsole::putc` in a loop.
250+
The second solution keeps the POSIX layer with the main saving coming from dropping the use of `FileHandle` and the file handle table itself. In this case, a `MinimalConsole` class will be implemented as an internal class in the retarget code and `write()` will call `MinimalConsole::putc` in a loop.
251+
252+
```C
253+
class MinimalConsole {
254+
public:
255+
MinimalConsole(int baud = MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE);
256+
~MinimalConsole();
257+
int getc();
258+
int putc(int c);
259+
};
260+
```
283261

284262
List of tasks to simplify the retarget code:
285263

0 commit comments

Comments
 (0)