Skip to content

Commit 28564ea

Browse files
authored
fix(uart_ci): keeping previous formatting and applying changes
1 parent 6be85a3 commit 28564ea

File tree

1 file changed

+63
-63
lines changed

1 file changed

+63
-63
lines changed

tests/validation/uart/uart.ino

+63-63
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/* UART test
2-
3-
This test is using UART0 (Serial) only for reporting test status and helping with the auto
4-
baudrate detection test.
5-
The other serials are used for testing.
6-
*/
2+
*
3+
* This test is using UART0 (Serial) only for reporting test status and helping with the auto
4+
* baudrate detection test.
5+
* The other serials are used for testing.
6+
*/
77

88
// Default pins:
99
// | Name | ESP32 | S2 | S3 | C3 | C6 | H2 | P4 |
@@ -15,18 +15,18 @@
1515
// UART2 TX | TX2 | 25 | -- | 20 | -- | -- | -- | -- |
1616

1717
/*
18-
For each UART:
19-
20-
terminal
21-
| ^
22-
v UART0 |
23-
RX ^ TX
24-
|
25-
report status
26-
|
27-
TX <---> RX
28-
UARTx
29-
*/
18+
* For each UART:
19+
*
20+
* terminal
21+
* | ^
22+
* v UART0 |
23+
* RX ^ TX
24+
* |
25+
* report status
26+
* |
27+
* TX <---> RX
28+
* UARTx
29+
*/
3030

3131
#include <vector>
3232
#include <unity.h>
@@ -41,58 +41,58 @@
4141
/* Utility classes */
4242

4343
class UARTTestConfig {
44-
public:
45-
int uart_num;
46-
HardwareSerial &serial;
47-
int peeked_char;
48-
int8_t default_rx_pin;
49-
int8_t default_tx_pin;
50-
String recv_msg;
51-
52-
UARTTestConfig(int num, HardwareSerial &serial_ref, int8_t rx_pin, int8_t tx_pin)
53-
: uart_num(num), serial(serial_ref), peeked_char(-1), default_rx_pin(rx_pin), default_tx_pin(tx_pin), recv_msg("") {}
54-
55-
void begin(unsigned long baudrate) {
56-
// pinMode will force enabing the internal pullup resistor (IDF 5.3.2 Change)
57-
pinMode(default_rx_pin, INPUT_PULLUP);
58-
serial.begin(baudrate, SERIAL_8N1, default_rx_pin, default_tx_pin);
59-
while (!serial) {
60-
delay(10);
61-
}
44+
public:
45+
int uart_num;
46+
HardwareSerial &serial;
47+
int peeked_char;
48+
int8_t default_rx_pin;
49+
int8_t default_tx_pin;
50+
String recv_msg;
51+
52+
UARTTestConfig(int num, HardwareSerial &serial_ref, int8_t rx_pin, int8_t tx_pin)
53+
: uart_num(num), serial(serial_ref), peeked_char(-1), default_rx_pin(rx_pin), default_tx_pin(tx_pin), recv_msg("") {}
54+
55+
void begin(unsigned long baudrate) {
56+
// pinMode will force enabing the internal pullup resistor (IDF 5.3.2 Change)
57+
pinMode(default_rx_pin, INPUT_PULLUP);
58+
serial.begin(baudrate, SERIAL_8N1, default_rx_pin, default_tx_pin);
59+
while (!serial) {
60+
delay(10);
6261
}
62+
}
6363

64-
void end() {
65-
serial.end();
66-
}
64+
void end() {
65+
serial.end();
66+
}
6767

68-
void reset_buffers() {
69-
recv_msg = "";
70-
peeked_char = -1;
71-
}
68+
void reset_buffers() {
69+
recv_msg = "";
70+
peeked_char = -1;
71+
}
7272

73-
void transmit_and_check_msg(const String &msg_append, bool perform_assert = true) {
74-
reset_buffers();
75-
delay(100);
76-
serial.print("Hello from Serial" + String(uart_num) + " " + msg_append);
77-
serial.flush();
78-
delay(100);
79-
if (perform_assert) {
80-
TEST_ASSERT_EQUAL_STRING(("Hello from Serial" + String(uart_num) + " " + msg_append).c_str(), recv_msg.c_str());
81-
log_d("UART%d received message: %s\n", uart_num, recv_msg.c_str());
82-
}
73+
void transmit_and_check_msg(const String &msg_append, bool perform_assert = true) {
74+
reset_buffers();
75+
delay(100);
76+
serial.print("Hello from Serial" + String(uart_num) + " " + msg_append);
77+
serial.flush();
78+
delay(100);
79+
if (perform_assert) {
80+
TEST_ASSERT_EQUAL_STRING(("Hello from Serial" + String(uart_num) + " " + msg_append).c_str(), recv_msg.c_str());
81+
log_d("UART%d received message: %s\n", uart_num, recv_msg.c_str());
8382
}
83+
}
8484

85-
void onReceive() {
86-
char c;
87-
size_t available = serial.available();
88-
if (peeked_char == -1) {
89-
peeked_char = serial.peek();
90-
}
91-
while (available--) {
92-
c = (char)serial.read();
93-
recv_msg += c;
94-
}
85+
void onReceive() {
86+
char c;
87+
size_t available = serial.available();
88+
if (peeked_char == -1) {
89+
peeked_char = serial.peek();
90+
}
91+
while (available--) {
92+
c = (char)serial.read();
93+
recv_msg += c;
9594
}
95+
}
9696
};
9797

9898
/* Utility global variables */
@@ -450,8 +450,8 @@ void periman_test(void) {
450450
TEST_ASSERT_EQUAL_STRING("", config.recv_msg.c_str());
451451

452452
log_d("Disabling I2C and re-enabling UART%d", config.uart_num);
453-
config.serial.setPins(config.default_rx_pin, config.default_tx_pin);
454453

454+
config.serial.setPins(config.default_rx_pin, config.default_tx_pin);
455455
uart_internal_loopback(config.uart_num, config.default_rx_pin);
456456

457457
log_d("Trying to send message using UART%d with I2C disabled", config.uart_num);

0 commit comments

Comments
 (0)