Skip to content

Commit 3fecfce

Browse files
authored
feat: Mutex NULL testing
1 parent 9419312 commit 3fecfce

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ SemaphoreHandle_t uart_buffer_Mutex = NULL;
7070
// task created when onReceive() is used
7171
void UART0_RX_CB() {
7272
// take the mutex, waits forever until loop() finishes its processing
73-
if (uart_buffer_Mutex != NULL && xSemaphoreTake(uart_buffer_Mutex, portMAX_DELAY)) {
73+
if (xSemaphoreTake(uart_buffer_Mutex, portMAX_DELAY)) {
7474
uint32_t now = millis(); // tracks timeout
7575
while ((millis() - now) < communicationTimeout_ms) {
7676
if (UART0.available()) {
@@ -106,7 +106,7 @@ uint32_t counter = 0;
106106
void loop() {
107107
if (uart_buffer.length() > 0) {
108108
// signals that the onReceive function shall not change uart_buffer while processing
109-
if (uart_buffer_Mutex != NULL && xSemaphoreTake(uart_buffer_Mutex, portMAX_DELAY)) {
109+
if (xSemaphoreTake(uart_buffer_Mutex, portMAX_DELAY)) {
110110
// process the received data from UART0 - example, just print it beside a counter
111111
UART0.print("[");
112112
UART0.print(counter++);

0 commit comments

Comments
 (0)