Alternative to ESP_ERROR_CHECK

User avatar
kolban
Posts: 1001
Joined: Mon Nov 16, 2015 4:43 pm
Location: Texas, USA

Alternative to ESP_ERROR_CHECK

Postby kolban » Tue Feb 14, 2017 2:30 am

The ESP-IDF provides a useful macro called ESP_ERROR_CHECK() that takes a statement as a parameter. If the statement does NOT return ESP_OK, then we assert and log the line. Unfortunately, this doesn't include the error code value that was actually returned by the statement.

Here is an alternative definition which logs the error code in addition to throwing an assertion:

Code: Select all

#undef ESP_ERROR_CHECK
#define ESP_ERROR_CHECK(x)   do { esp_err_t rc = (x); if (rc != ESP_OK) { ESP_LOGE("err", "esp_err_t = %d", rc); assert(0 && #x);} } while(0);
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

ESP_Angus
Posts: 534
Joined: Sun May 08, 2016 4:11 am

Re: Alternative to ESP_ERROR_CHECK

Postby ESP_Angus » Tue Feb 14, 2017 3:14 am

Hi Kolban,

Good addition. Could you please send this as a pull request on github? We'll likely incorporate it into esp-idf.

Angus

BuddyCasino
Posts: 226
Joined: Sun Jun 19, 2016 12:00 am

Re: Alternative to ESP_ERROR_CHECK

Postby BuddyCasino » Fri Mar 31, 2017 6:53 pm

Very nice! This has bugged me too, didn't know it is that easy to contribute.

Bmillier
Posts: 2
Joined: Sun Aug 13, 2017 12:52 am

Re: Alternative to ESP_ERROR_CHECK

Postby Bmillier » Mon Sep 25, 2017 5:34 pm

Hi Neil
This is off topic: I love your book. Have used it on several projects, the latest being a learning IR remote/ wifi blaster using RMT peripheral. I note on page 255 you show max values of 65535 for the 15- bit timing value saved by the RMT peripheral. This should be 32767.
Using the Arduino IDE and my own drivers, I have gotten the IR transmit function working fine using
LIRC conf files for the IR data structure, as a test. I just got the basic IR receive function working for the "learning" part, but there's more work needed to handle the wide range of IR signals that the different remotes emit.
This would be easier to do if I were using the Espressif IDF, but that's more than I want to bite off right now.

Who is online

Users browsing this forum: No registered users and 1 guest