Skip to content

Commit 037924a

Browse files
committed
Replace RawSerial instances as it has been deprecated
1 parent d128ff4 commit 037924a

File tree

19 files changed

+125
-121
lines changed

19 files changed

+125
-121
lines changed

TESTS/mbed_drivers/flashiap/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#else
2121

2222
#include "utest/utest.h"
23-
#include "utest/utest_serial.h"
23+
#include "utest/utest_print.h"
2424
#include "unity/unity.h"
2525
#include "greentea-client/test_env.h"
2626
#include "FlashIAP.h"

TEST_APPS/device/nanostack_mac_tester/main.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
#endif
4545

4646
extern mac_api_s *mac_interface;
47-
RawSerial pc(USBTX, USBRX);
47+
UnbufferedSerial pc(USBTX, USBRX);
4848
osThreadId_t main_thread;
4949
static CircularBuffer<uint8_t, RX_BUFFER_SIZE> rx_buffer;
5050
static uint8_t ns_heap[HEAP_FOR_MAC_TESTER_SIZE];
@@ -68,7 +68,8 @@ static void app_heap_error_handler(heap_fail_t event)
6868

6969
static void rx_interrupt(void)
7070
{
71-
uint8_t c = pc.getc();
71+
uint8_t c;
72+
pc.read(&c, 1);
7273
rx_buffer.push(c);
7374
if (main_thread != NULL) {
7475
osThreadFlagsSet(main_thread, 1);

drivers/RawSerial.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,6 @@
2727
#include <cstdarg>
2828

2929
namespace mbed {
30-
/** \defgroup drivers-public-api-uart UART
31-
* \ingroup drivers-public-api
32-
*/
3330

3431
/**
3532
* \defgroup drivers_RawSerial RawSerial class

drivers/UnbufferedSerial.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@
3030

3131

3232
namespace mbed {
33+
/** \defgroup drivers-public-api-uart UART
34+
* \ingroup drivers-public-api
35+
*/
3336

3437
/**
3538
* \defgroup drivers_UnbufferedSerial UnbufferedSerial class

features/FEATURE_BLE/targets/TARGET_CORDIO/driver/H4TransportDriver.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,9 @@ class H4TransportDriver : public CordioHCITransportDriver {
6969
private:
7070
void on_controller_irq();
7171

72-
// Use RawSerial as opposed to Serial as we don't require the locking primitives
73-
// provided by the Serial class (access to the UART should be exclusive to this driver)
74-
// Furthermore, we access the peripheral in interrupt context which would clash
75-
// with Serial's locking facilities
76-
RawSerial uart;
72+
// Use UnbufferedSerial as we don't require locking primitives.
73+
// We access the peripheral in interrupt context.
74+
UnbufferedSerial uart;
7775
PinName cts;
7876
PinName rts;
7977
};

features/FEATURE_BLE/targets/TARGET_Cypress/COMPONENT_CYW43XXX/CyH4TransportDriver.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,9 @@ class CyH4TransportDriver : public cordio::CordioHCITransportDriver {
8282
void assert_bt_dev_wake();
8383
void deassert_bt_dev_wake();
8484

85-
// Use RawSerial as opposed to Serial as we don't require the locking primitives
86-
// provided by the Serial class (access to the UART should be exclusive to this driver)
87-
// Furthermore, we access the peripheral in interrupt context which would clash
88-
// with Serial's locking facilities
89-
RawSerial uart;
85+
// Use UnbufferedSerial as we don't require locking primitives.
86+
// We access the peripheral in interrupt context.
87+
UnbufferedSerial uart;
9088
PinName cts;
9189
PinName rts;
9290
PinName bt_host_wake_name;

features/frameworks/greentea-client/greentea-client/greentea_serial.h

Lines changed: 0 additions & 21 deletions
This file was deleted.

features/frameworks/greentea-client/greentea-client/test_env.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,8 @@ void greentea_send_kv(const char * key, const char * val);
117117
int greentea_parse_kv(char * key, char * val,
118118
const int key_len, const int val_len);
119119
int greentea_getc();
120+
void greentea_putc(int c);
121+
void greentea_write_string(const char *str);
120122

121123
#ifdef __cplusplus
122124
}

features/frameworks/greentea-client/source/greentea_serial.cpp

Lines changed: 0 additions & 27 deletions
This file was deleted.

features/frameworks/greentea-client/source/greentea_test_env.cpp

Lines changed: 40 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,13 @@
1515
* limitations under the License.
1616
*/
1717

18-
#if DEVICE_SERIAL
19-
2018
#include <ctype.h>
2119
#include <cstdio>
2220
#include <string.h>
2321
#include "greentea-client/test_env.h"
24-
#include "greentea-client/greentea_serial.h"
2522
#include "greentea-client/greentea_metrics.h"
2623
#include "mbed_trace.h"
24+
#include "platform/mbed_retarget.h"
2725

2826
/**
2927
* Generic test suite transport protocol keys
@@ -59,7 +57,6 @@ static void greentea_notify_timeout(const int);
5957
static void greentea_notify_hosttest(const char *);
6058
static void greentea_notify_completion(const int);
6159
static void greentea_notify_version();
62-
static void greentea_write_string(const char *str);
6360

6461
/** \brief Handle the handshake with the host
6562
* \details This is contains the shared handhshake functionality that is used between
@@ -212,53 +209,51 @@ void greentea_notify_coverage_end() {
212209
*
213210
* This function writes the preamble "{{" which is required
214211
* for key-value comunication between the target and the host.
215-
* This uses a Rawserial object, greentea_serial, which provides
216-
* a direct interface to the USBTX and USBRX serial pins and allows
217-
* the direct writing of characters using the putc() method.
212+
* This uses greentea_putc which allows the direct writing of characters
213+
* using the write() method.
218214
* This suite of functions are provided to allow for serial communication
219215
* to the host from within a thread/ISR.
220-
*
221216
*/
222217
inline void greentea_write_preamble()
223218
{
224-
greentea_serial->putc('{');
225-
greentea_serial->putc('{');
219+
greentea_putc('{');
220+
greentea_putc('{');
226221
}
227222

228223
/**
229224
* \brief Write the postamble characters to the serial port
230225
*
231226
* This function writes the postamble "{{\n" which is required
232227
* for key-value comunication between the target and the host.
233-
* This uses a Rawserial object, greentea_serial, which provides
234-
* a direct interface to the USBTX and USBRX serial pins and allows
235-
* the direct writing of characters using the putc() method.
228+
* This uses greentea_putc which allows the direct writing of characters
229+
* using the write() method.
236230
* This suite of functions are provided to allow for serial communication
237231
* to the host from within a thread/ISR.
238232
*
239233
*/
240234
inline void greentea_write_postamble()
241235
{
242-
greentea_serial->putc('}');
243-
greentea_serial->putc('}');
244-
greentea_serial->putc('\r');
245-
greentea_serial->putc('\n');
236+
greentea_putc('}');
237+
greentea_putc('}');
238+
greentea_putc('\r');
239+
greentea_putc('\n');
246240
}
247241

248242
/**
249243
* \brief Write a string to the serial port
250244
*
251245
* This function writes a '\0' terminated string from the target
252246
* to the host. It writes directly to the serial port using the
253-
* greentea_serial, Rawserial object.
247+
* greentea_putc which allows the direct writing of characters
248+
* using the write() method.
254249
*
255250
* \param str - string value
256251
*
257252
*/
258253
inline void greentea_write_string(const char *str)
259254
{
260255
while (*str != '\0') {
261-
greentea_serial->putc(*str);
256+
greentea_putc(*str);
262257
str ++;
263258
}
264259
}
@@ -270,7 +265,7 @@ inline void greentea_write_string(const char *str)
270265
* This function writes an integer value from the target
271266
* to the host. The integer value is converted to a string and
272267
* and then written character by character directly to the serial
273-
* port using the greentea_serial, Rawserial object.
268+
* port using the console.
274269
* sprintf() is used to convert the int to a string. Sprintf if
275270
* inherently thread safe so can be used.
276271
*
@@ -284,7 +279,7 @@ inline void greentea_write_int(const int val)
284279
unsigned int i = 0;
285280
sprintf(intval, "%d", val);
286281
while (intval[i] != '\0') {
287-
greentea_serial->putc(intval[i]);
282+
greentea_putc(intval[i]);
288283
i++;
289284
}
290285
}
@@ -304,7 +299,7 @@ extern "C" void greentea_send_kv(const char *key, const char *val) {
304299
if (key && val) {
305300
greentea_write_preamble();
306301
greentea_write_string(key);
307-
greentea_serial->putc(';');
302+
greentea_putc(';');
308303
greentea_write_string(val);
309304
greentea_write_postamble();
310305
}
@@ -327,7 +322,7 @@ void greentea_send_kv(const char *key, const int val) {
327322
if (key) {
328323
greentea_write_preamble();
329324
greentea_write_string(key);
330-
greentea_serial->putc(';');
325+
greentea_putc(';');
331326
greentea_write_int(val);
332327
greentea_write_postamble();
333328
}
@@ -351,9 +346,9 @@ void greentea_send_kv(const char *key, const char *val, const int result) {
351346
if (key) {
352347
greentea_write_preamble();
353348
greentea_write_string(key);
354-
greentea_serial->putc(';');
349+
greentea_putc(';');
355350
greentea_write_string(val);
356-
greentea_serial->putc(';');
351+
greentea_putc(';');
357352
greentea_write_int(result);
358353
greentea_write_postamble();
359354

@@ -384,11 +379,11 @@ void greentea_send_kv(const char *key, const char *val, const int passes, const
384379
if (key) {
385380
greentea_write_preamble();
386381
greentea_write_string(key);
387-
greentea_serial->putc(';');
382+
greentea_putc(';');
388383
greentea_write_string(val);
389-
greentea_serial->putc(';');
384+
greentea_putc(';');
390385
greentea_write_int(passes);
391-
greentea_serial->putc(';');
386+
greentea_putc(';');
392387
greentea_write_int(failures);
393388
greentea_write_postamble();
394389
}
@@ -417,9 +412,9 @@ void greentea_send_kv(const char *key, const int passes, const int failures) {
417412
if (key) {
418413
greentea_write_preamble();
419414
greentea_write_string(key);
420-
greentea_serial->putc(';');
415+
greentea_putc(';');
421416
greentea_write_int(passes);
422-
greentea_serial->putc(';');
417+
greentea_putc(';');
423418
greentea_write_int(failures);
424419
greentea_write_postamble();
425420
}
@@ -562,7 +557,21 @@ enum Token {
562557
*
563558
*/
564559
extern "C" int greentea_getc() {
565-
return greentea_serial->getc();
560+
uint8_t c;
561+
read(STDERR_FILENO, &c, 1);
562+
return c;
563+
}
564+
565+
566+
/**
567+
* \brief Write character from stream of data
568+
*
569+
* \return The number of bytes written
570+
*
571+
*/
572+
extern "C" void greentea_putc(int c) {
573+
uint8_t _c = c;
574+
write(STDERR_FILENO, &_c, 1);
566575
}
567576

568577
/**
@@ -786,5 +795,3 @@ static int HandleKV(char *out_key,
786795
getNextToken(0, 0);
787796
return 0;
788797
}
789-
790-
#endif

features/frameworks/utest/source/unity_handler.cpp

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,8 @@
1919
#include "utest/utest_harness.h"
2020
#include "utest/utest_stack_trace.h"
2121
#include "utest/unity_handler.h"
22+
#include "greentea-client/test_env.h"
2223

23-
#if DEVICE_SERIAL
24-
#include "greentea-client/greentea_serial.h"
25-
#endif
2624

2725
void utest_unity_assert_failure(void)
2826
{
@@ -36,10 +34,7 @@ void utest_unity_ignore_failure(void)
3634
utest::v1::Harness::raise_failure(utest::v1::failure_reason_t(utest::v1::REASON_ASSERTION | utest::v1::REASON_IGNORE));
3735
}
3836

39-
#if DEVICE_SERIAL
4037
void utest_safe_putc(int chr)
4138
{
42-
greentea_serial->putc(chr);
43-
}
44-
#endif
45-
39+
greentea_putc(chr);
40+
}

features/frameworks/utest/source/utest_case.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
*/
1818

1919
#include "utest/utest_case.h"
20-
#include "utest/utest_serial.h"
20+
#include "utest/utest_print.h"
2121

2222
using namespace utest::v1;
2323

features/frameworks/utest/source/utest_default_handlers.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#include "utest/utest_default_handlers.h"
2222
#include "utest/utest_case.h"
2323
#include "utest/utest_stack_trace.h"
24-
#include "utest/utest_serial.h"
24+
#include "utest/utest_print.h"
2525

2626
using namespace utest::v1;
2727

features/frameworks/utest/source/utest_greentea_handlers.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#include "utest/utest_case.h"
2121
#include "greentea-client/test_env.h"
2222
#include "utest/utest_stack_trace.h"
23-
#include "utest/utest_serial.h"
23+
#include "utest/utest_print.h"
2424

2525
using namespace utest::v1;
2626

features/frameworks/utest/source/utest_harness.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
#include "utest/utest_harness.h"
2020
#include "utest/utest_stack_trace.h"
21-
#include "utest/utest_serial.h"
21+
#include "utest/utest_print.h"
2222

2323
#include <stdlib.h>
2424

0 commit comments

Comments
 (0)