Skip to content

Commit 9419312

Browse files
authored
feat: Mutex error message
1 parent d2007e1 commit 9419312

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

Diff for: libraries/ESP32/examples/Serial/onReceiveExample/onReceiveExample.ino

+9-4
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,18 @@ void UART0_RX_CB() {
8686
// setup() and loop() are functions executed by a low priority task
8787
// Therefore, there are 2 tasks running when using onReceive()
8888
void setup() {
89+
UART0.begin(115200);
90+
8991
// creates a mutex object to control access to uart_buffer
9092
uart_buffer_Mutex = xSemaphoreCreateMutex();
9193
if(uart_buffer_Mutex == NULL) {
92-
log_e("Error creating Mutex. Sketch will fail.");
93-
delay(1000);
94+
log_e("Error creating Mutex. Sketch will fail.");
95+
while(true) {
96+
UART0.println("Mutex error (NULL). Program halted.");
97+
delay(2000);
98+
}
9499
}
95-
UART0.begin(115200);
100+
96101
UART0.onReceive(UART0_RX_CB); // sets the callback function
97102
UART0.println("Send data to UART0 in order to activate the RX callback");
98103
}
@@ -113,7 +118,7 @@ void loop() {
113118
// releases the mutex for more data to be received
114119
xSemaphoreGive(uart_buffer_Mutex);
115120
}
116-
}
121+
}
117122
UART0.println("Sleeping for 1 second...");
118123
delay(1000);
119124
}

0 commit comments

Comments
 (0)