Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calling IRrecv.enableIRIn() after calling IRrecv.enableIRIn() fails to attach timer handler #1983

Closed
homy-newfs8 opened this issue May 2, 2023 · 4 comments · Fixed by #1984
Assignees
Labels
bug ESP32 ESP32 only issue Pending Confirmation Waiting for confirmation from user

Comments

@homy-newfs8
Copy link

Version/revision of the library used

2.8.4

Describe the bug

Calling IRrecv.enableIRIn() after calling IRrecv.enableIRIn() fails to attach timer handler, and receive timeout does not work.
Tested on ESP32 Arduino 2.0.8 based on ESP-IDF 4.4.4.

To Reproduce

Code below produces framework error message timer_group: timer_isr_callback_add(236): register interrupt service failed,
and IRrecv.decode() does not finish until buffer overflow. I used compiler flags: -DDEBUG -D_IR_ENABLE_DEFAULT_=false -DDECODE_HASH=true.

Example code used

#include <Arduino.h>
#include <IRrecv.h>

IRrecv recv{32, 256, 15};

void
setup() {
  Serial.begin(115200);
  delay(3000);

  recv.enableIRIn();
  recv.disableIRIn();
  recv.enableIRIn();
}

bool done;

void
loop() {
  decode_results results;
  if (!done && recv.decode(&results)) {
    Serial.printf("rawlen = %u, overflow = %u\n", results.rawlen, results.overflow);
    Serial.println("Decode done");
    done = true;
  }
  delay(1);
}

Output:

E (5039) timer_group: timer_isr_callback_add(236): register interrupt service failed
rawlen = 256, overflow = 1
Decode done

Expected behaviour

IRrecv.enableIRIn does not produce system error and IRrecv.decode() returns with proper length of data.

What brand/model IR demodulator are you using?

M5Atom Lite with IR UNIT

Other useful information

Call timerDetachInterrupt() in disableIRIn() seems fix this problem.

@crankyoldgit crankyoldgit self-assigned this May 3, 2023
crankyoldgit added a commit that referenced this issue May 3, 2023
Kudos to @homy-newfs8 for finding, isolating, and providing a fix for the bug.

Fixes #1983
@crankyoldgit crankyoldgit added the ESP32 ESP32 only issue label May 3, 2023
@crankyoldgit
Copy link
Owner

@homy-newfs8 Thanks for reporting this. Yes, I do seem to miss clearing that Interrupt. Well spotted.

Can you please confirm that branch ESP32_timerDetachInterrupt_bug / PR #1984 addresses the problem for you?

@crankyoldgit crankyoldgit added the Pending Confirmation Waiting for confirmation from user label May 3, 2023
@homy-newfs8
Copy link
Author

Tested the branch version. Above example code produces these messages:

E (3042) timer_group: timer_isr_callback_remove(246): HW TIMER NEVER INIT ERROR
E (3043) timer_group: timer_isr_callback_add(236): register interrupt service failed

It seems timerDetachInterrupt() must be called before timerEnd().

@crankyoldgit
Copy link
Owner

Thanks for that info. I've moved it before timerEnd() now. Can you download/pull etc that branch and try it again?

@homy-newfs8
Copy link
Author

Confirmd the problem fixed on the branch. Example code outputs no error messages and my personal project starts working well 😄
Thank you 🙏

crankyoldgit added a commit that referenced this issue May 4, 2023
Kudos to @homy-newfs8 for finding, isolating, and providing a fix for the bug.
Note: `timerEnd()` needs to happen after `timerDetachInterrupt()`

Fixes #1983
crankyoldgit added a commit that referenced this issue May 8, 2023
_v2.8.5 (20230508)_

**[Bug Fixes]**
- Fix a bug where we never detached the timer interrupt on ESP32s. (#1984 #1983)
- Missing argument in use of midea function (#1959 #1958)
- IRMQTTServer: Improve HA MQTT climate handling. (#1911)
- SEND_SANYO_AC88: Fix poor cut-n-paste error (#1905 #1897)

**[Features]**
- Add support for a 40bit variant of the standard Panasonic protocol (#1977 @1976)
- Initial support for York AC protocol (#1889)
- IRMQTTServer: SHT-3x Temperature Sensor Support (#1951)
- IRMQTTServer: HA multi output discovery (#1947)
- IRMQTTServer: extended with new A/C common fields (#1940)
- IRMQTTServer: Sync the on state to power from mode for HA (#1946)
- Experimental basic support for Carrier 84-bit protocol. (#1945 #1943)
- Add support the WowWee 11-Bit RoboRaptor-X protocol. (#1939 #1938)
- Added 'sensorTemperature' and 'iFeel' to IRac (common) (#1928)
- Added extra 'mid' option for Fan & SwingV to IRac (#1929)
- Added "commandType" to IRAc (#1921)
- Added support for Argo WREM-3 A/C remote protocol [part1] (#1920)
- Added Dutch (nl-NL) translation (#1907)
- ARGO: Improve code & add support for decoding 32bit sensor msgs. (#1906 #1859)
- Added support for Gorenje cooker hood IR protocol (#1888 #1887)

**[Misc]**
- Add Electrolux YKR-H/531E as a supported device (#1981 #1980)
- Update `XMP` status to Stable (#1944)
- upgrade to a later version of `googletest` (#1936)
- MITSUBISHI128: Added model to supported protocol (#1924)
- Added Dutch (nl-NL) README (#1908)
- Added GMock to UT Makefile (#1902)
- Update HA example config for HA 2022.6+ (#1901 #1900)
- Add a `d1_mini_noMDNS` build option to `IRMQTTServer`. (#1985)
crankyoldgit added a commit that referenced this issue May 8, 2023
## _v2.8.5 (20230508)_

**[Bug Fixes]**
- Fix a bug where we never detached the timer interrupt on ESP32s. (#1984 #1983)
- Missing argument in use of midea function (#1959 #1958)
- IRMQTTServer: Improve HA MQTT climate handling. (#1911)
- SEND_SANYO_AC88: Fix poor cut-n-paste error (#1905 #1897)

**[Features]**
- Add support for a 40bit variant of the standard Panasonic protocol (#1977 @1976)
- Initial support for York AC protocol (#1889)
- IRMQTTServer: SHT-3x Temperature Sensor Support (#1951)
- IRMQTTServer: HA multi output discovery (#1947)
- IRMQTTServer: extended with new A/C common fields (#1940)
- IRMQTTServer: Sync the on state to power from mode for HA (#1946)
- Experimental basic support for Carrier 84-bit protocol. (#1945 #1943)
- Add support the WowWee 11-Bit RoboRaptor-X protocol. (#1939 #1938)
- Added 'sensorTemperature' and 'iFeel' to IRac (common) (#1928)
- Added extra 'mid' option for Fan & SwingV to IRac (#1929)
- Added "commandType" to IRAc (#1921)
- Added support for Argo WREM-3 A/C remote protocol [part1] (#1920)
- Added Dutch (nl-NL) translation (#1907)
- ARGO: Improve code & add support for decoding 32bit sensor msgs. (#1906 #1859)
- Added support for Gorenje cooker hood IR protocol (#1888 #1887)

**[Misc]**
- Add Electrolux YKR-H/531E as a supported device (#1981 #1980)
- Update `XMP` status to Stable (#1944)
- upgrade to a later version of `googletest` (#1936)
- MITSUBISHI128: Added model to supported protocol (#1924)
- Added Dutch (nl-NL) README (#1908)
- Added GMock to UT Makefile (#1902)
- Update HA example config for HA 2022.6+ (#1901 #1900)
- Add a `d1_mini_noMDNS` build option to `IRMQTTServer`. (#1985)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug ESP32 ESP32 only issue Pending Confirmation Waiting for confirmation from user
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants