GithubHelp home page GithubHelp logo

Comments (15)

WoodsterDK avatar WoodsterDK commented on June 26, 2024

Nice find.... I have been looking a lot for this.
Will try this later today, to see if it solves the problem.

from rc-switch.

WoodsterDK avatar WoodsterDK commented on June 26, 2024

Seems to solve my instability issue.

from rc-switch.

fingolfin avatar fingolfin commented on June 26, 2024

I tried to fix this in 90d00c1 based on your description. Could you please verify whether that actually works for you?

from rc-switch.

RalfJL avatar RalfJL commented on June 26, 2024

Yes,

thanks, works
I like the implementation.

from rc-switch.

WheresWally avatar WheresWally commented on June 26, 2024

I had to do this to the .cpp file to get it to work on a ESP8266-01 with the data connected to GPIO-02

#ifdef ESP8266
void ICACHE_RAM_ATTR RCSwitch::handleInterrupt() {
#else
//void RCSwitch::handleInterrupt() {
void RECEIVE_ATTR RCSwitch::handleInterrupt() {
#endif

Otherwise, thanks heaps.

I am making a range extender for a CareAlert smart dialer using 2x EPS8266 with a 434Mhz Receicer on one unit and a 434Mhz transmitter on the other.
Which now works....

from rc-switch.

eiannone avatar eiannone commented on June 26, 2024

@WheresWally , this shouldn't be necessary, as you can see in the macro starting at line 43, where RECEIVE_ATTR is already substituted with ICACHE_RAM_ATTR for ESP8266:

#ifdef ESP8266
    // interrupt handler and related code must be in RAM on ESP8266,
    // according to issue #46.
    #define RECEIVE_ATTR ICACHE_RAM_ATTR
#else
    #define RECEIVE_ATTR
#endif

from rc-switch.

gadget1999 avatar gadget1999 commented on June 26, 2024

I also have similar issue on ESP8266 that random crash happens when interrupt is called. I also added ICACHE_RAM_ATTR to RCSwitch::handleInterrupt() and now problem is solved.

from rc-switch.

fingolfin avatar fingolfin commented on June 26, 2024

@gadget1999 Well, we already have a fix for that in the code -- are you using the latest version of rc-switch? If so, can you please test whether ESP8266 is #defined for you? E.g. put this into your code, and compile it:

#ifdef ESP8266
#error  ESP8266 is defined
#else
#error ESP8266 is NOT defined
#endif

If the issue persists with the latest rc-switch, as taken from this repository, please open a new issue for this, instead of adding to an old, already closed one.

from rc-switch.

gadget1999 avatar gadget1999 commented on June 26, 2024

@fingolfin , thanks for the direction, I can reproduce the issue with "#error ESP8266 is defined". I'll open a new issue then.

from rc-switch.

PTDreamer avatar PTDreamer commented on June 26, 2024

@gadget1999 Well, we already have a fix for that in the code -- are you using the latest version of rc-switch?

The fix is not on the latest release (v2.52) which is what is used with for example platformio library manager.
Could you please pick a branch/revision with code you consider stable and hit the create release button :)

from rc-switch.

gadget1999 avatar gadget1999 commented on June 26, 2024

sorry never used github to commit code before, I'll need to learn how to do it first and make the change later. All the change I made locally was the same as @WheresWally did above:

#ifdef ESP8266
void ICACHE_RAM_ATTR RCSwitch::handleInterrupt() {
#else
//void RCSwitch::handleInterrupt() {
void RECEIVE_ATTR RCSwitch::handleInterrupt() {
#endif

from rc-switch.

benthans1 avatar benthans1 commented on June 26, 2024

Here is the actual bug:
/* helper function for the receiveProtocol method */
static inline unsigned int diff(int A, int B) {
//return abs(A - B); // it's not a language build in function and not declared with RECEIVE_ATTR
//replacement:
if ((A - B)>0) return (A - B); else return -(A - B) ;
}

from rc-switch.

benthans1 avatar benthans1 commented on June 26, 2024

Someone should fix this bug in the master lib and release a new version. I'm not currently willing to be in charge of such a release myself. If you are the right person to do it, please go ahead, but don’t mention me in the release, please.

from rc-switch.

benthans1 avatar benthans1 commented on June 26, 2024

Ok, I get it (having received a few messags from people that happen to know me). I need to explain further, so here comes...

The C library function int abs(int x) returns the absolute value of int x.

Note that it is a library function (stdlib.h) not a build in compiler function!
Since it is part of stdlib.h it is almost always available to you and usually there is no reason to concern yourself with using it. However in this special case we are dealing with an interrupt routine that has to always be available! If some other software has locked the memory that it needs you will be faced with a fubar if/when the interrupt occurs. It is therefore NOT ok to use a libary function in your interrupt routine!

Note:
In case you dont't know , 'fubar' is old millitary slang. It stand for "Fucked Up Beyond All Recogniction".

from rc-switch.

benthans1 avatar benthans1 commented on June 26, 2024

Sadly the use of micros() within an interrupt routine also seem to be unsafe, certainly on ESP32 platforms. Unfortunately this is not so easy to replace and I have yet to figure out what to suggest doing about it. At the moment I can’t even suggest a workaround. Also at the moment I lean towards thinking that this should be solved outside the scope of this project as the use of micros() in an interrupt routine is so fundamental that my thinking is that it really needs to be addressed in the platform lib not in a project lib.
Comments welcome please!

from rc-switch.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.