Skip to content

Commit 15dd18a

Browse files
committed
Incorporated the review comment
1 parent 3ee6d89 commit 15dd18a

File tree

1 file changed

+7
-38
lines changed

1 file changed

+7
-38
lines changed

TESTS/usb_device/serial/main.cpp

Lines changed: 7 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -149,11 +149,7 @@ line_coding_t test_codings[] = {
149149
{ 9600, 8, 0, 0 },
150150
{ 57600, 8, 0, 0 },
151151
};
152-
#if defined(MBED_CONF_RTOS_PRESENT)
153-
Mail<line_coding_t, 8> lc_mail;
154-
#else
155152
static CircularBuffer<line_coding_t, 8> lc_data;
156-
#endif
157153

158154
#define EF_SEND (1ul << 0)
159155
EventFlags event_flags;
@@ -773,14 +769,6 @@ void test_serial_printf_scanf()
773769

774770
void line_coding_changed_cb(int baud, int bits, int parity, int stop)
775771
{
776-
#if defined(MBED_CONF_RTOS_PRESENT)
777-
line_coding_t *lc = lc_mail.alloc();
778-
lc->baud = baud;
779-
lc->bits = bits;
780-
lc->parity = parity;
781-
lc->stop = stop;
782-
lc_mail.put(lc);
783-
#else
784772
line_coding_t lc = {
785773
.baud = baud,
786774
.bits = bits,
@@ -789,7 +777,6 @@ void line_coding_changed_cb(int baud, int bits, int parity, int stop)
789777
};
790778
lc_data.push(lc);
791779
event_flags.set(EF_SEND);
792-
#endif
793780
}
794781

795782
/** Test Serial / CDC line coding change
@@ -813,9 +800,9 @@ void test_serial_line_coding_change()
813800
size_t num_line_codings = sizeof test_codings / sizeof test_codings[0];
814801
line_coding_t *lc_prev = &default_lc;
815802
line_coding_t *lc_expected = NULL;
816-
line_coding_t *lc_actual = NULL;
817803
int num_expected_callbacks, rc;
818804
for (size_t i = 0; i < num_line_codings; i++) {
805+
line_coding_t lc_actual = {0};
819806
lc_expected = &(test_codings[i]);
820807
num_expected_callbacks = lc_prev->get_num_diffs(*lc_expected);
821808
rc = usb_serial.printf("%06i,%02i,%01i,%01i%c", lc_expected->baud, lc_expected->bits, lc_expected->parity,
@@ -827,34 +814,16 @@ void test_serial_line_coding_change()
827814
// calls to line_coding_changed callback on the device.
828815
while (num_expected_callbacks > 0) {
829816
num_expected_callbacks--;
830-
#if defined(MBED_CONF_RTOS_PRESENT)
831-
osEvent event = lc_mail.get();
832-
TEST_ASSERT_EQUAL_UINT32(osEventMail, event.status);
833-
lc_actual = (line_coding_t *) event.value.p;
834-
if (lc_expected->get_num_diffs(*lc_actual) == 0) {
835-
break;
836-
} else if (num_expected_callbacks > 0) {
837-
// Discard lc_actual only if there is still a chance to get new
838-
// set of params.
839-
lc_mail.free(lc_actual);
840-
}
841-
#else
842-
line_coding_t lc_receive = {0};
843817
event_flags.wait_all(EF_SEND);
844-
lc_data.pop(lc_receive);
845-
if (lc_expected->get_num_diffs(lc_receive) == 0) {
818+
lc_data.pop(lc_actual);
819+
if (lc_expected->get_num_diffs(lc_actual) == 0) {
846820
break;
847821
}
848-
lc_actual = &lc_receive;
849-
#endif
850822
}
851-
TEST_ASSERT_EQUAL_INT(lc_expected->baud, lc_actual->baud);
852-
TEST_ASSERT_EQUAL_INT(lc_expected->bits, lc_actual->bits);
853-
TEST_ASSERT_EQUAL_INT(lc_expected->parity, lc_actual->parity);
854-
TEST_ASSERT_EQUAL_INT(lc_expected->stop, lc_actual->stop);
855-
#if defined(MBED_CONF_RTOS_PRESENT)
856-
lc_mail.free(lc_actual);
857-
#endif
823+
TEST_ASSERT_EQUAL_INT(lc_expected->baud, lc_actual.baud);
824+
TEST_ASSERT_EQUAL_INT(lc_expected->bits, lc_actual.bits);
825+
TEST_ASSERT_EQUAL_INT(lc_expected->parity, lc_actual.parity);
826+
TEST_ASSERT_EQUAL_INT(lc_expected->stop, lc_actual.stop);
858827
lc_prev = lc_expected;
859828
}
860829
// Wait for the host to close its port.

0 commit comments

Comments
 (0)