GithubHelp home page GithubHelp logo

Connecting the two receivers about rc-switch HOT 13 CLOSED

sui77 avatar sui77 commented on June 26, 2024
Connecting the two receivers

from rc-switch.

Comments (13)

fingolfin avatar fingolfin commented on June 26, 2024

It's very hard to understand what you are saying.

But I am guessing you are requesting support for using two receivers simultaneously, which is currently not possible.

Unfortunately, there seems to be no "elegant" way to fix this. The problem is that RCSwitch::handleInterrupt has no way to know for which pin respectively interrupt it was invoked.

Since RCSwitch::handleInterrupt does not know the source of the interrupt, we cannot use it to pass data to multiple RCSwitch instances.

This is a limitation of the Arduino interrupt handling system, it seems :-/.

from rc-switch.

fingolfin avatar fingolfin commented on June 26, 2024

One hackish workaround: If we arbitrarily limit ourselves to e.g. 6 interrupts, we could provie six "outer" interrupt handlers; then modify attachInterrupt to use the correct handler for each interrupt. Next, we'd use a small global array to lookup which RCSwitch instance is assigned to which interrupt, and dispatch to that.

But that is still limited in flexibility and somewhat ugly. Hrm.

from rc-switch.

MeJIyA avatar MeJIyA commented on June 26, 2024

Sorry for my English. Thanks for the answer.

from rc-switch.

sui77 avatar sui77 commented on June 26, 2024

Another dirty hack that might work would be switching between both receivers once every second. Of course with the risk of missing some signals, depends on your needs.

void loop() {
mySwitch.enableReceive(0);
delay(1000);
mySwitch.enableReceive(1);
delay(1000);
}

from rc-switch.

MeJIyA avatar MeJIyA commented on June 26, 2024

sui77 Thank you. But I do not fit this option, you must monitor two frequencies at once. I implemented without interruption. But the accuracy lutshe wants to be, although operational.

from rc-switch.

MeJIyA avatar MeJIyA commented on June 26, 2024

Still managed to use the hack . delay ( 200 ) and set the tolerable results obtained .
Hedgehog Thanks again sui77.

from rc-switch.

bilogic avatar bilogic commented on June 26, 2024

Is there a reason why the class uses static definition? as in RCSwitch::?
I had the same need for 2 receivers and added code for a 2nd detection buffer. I can share the code if it helps, but I thought the best way was to use a non static approach.

from rc-switch.

MeJIyA avatar MeJIyA commented on June 26, 2024

Thank you , I have long been solved the problem of writing separate code to the second receiver .

22 травня 2016, 12:53:35, від "bilogic" < [email protected] >:

Is there a reason why the class uses static definition? as in RCSwitch::?
I had the same need for 2 receivers and added code for an 2nd detection buffer. I can share the code if it helps, but I thought the best way was to use a non static approach. —
You are receiving this because you commented.
Reply to this email directly or view it on GitHub

from rc-switch.

fingolfin avatar fingolfin commented on June 26, 2024

@bilogic The class uses static definitions because Arduino interrupt handler callbacks sadly only can access static / global data; and interrupt handlers cannot easily be shared for different users. In particular, they have no void *refCon parameter, which many other callback based APIs offer.

So I am really curious to learn how you bypassed that problem. But please let's not put it onto this old, closed issue; instead, submit a pull request, and/or a new issue where you explain your changes.

from rc-switch.

MeJIyA avatar MeJIyA commented on June 26, 2024

My level of English is low and I did not understand everything. But answer me more . I used the library on the same frequency , but dorabatival library. I added Oregon and Lacrose. I also added support for long codes for other sensor types. In the future, when I will modify the code I'll post the code . At the time of Danian though workable but not beautiful .
Another receiver potsepil I just interrupt and organized another function but to recognize only one protocol .
I just I measure the duration and analyze the code and decodes it . Though excessively but it works.
23 травня 2016, 10:17:45, від "Max Horn" < [email protected] >:

@bilogic The class uses static definitions because Arduino interrupt handler callbacks sadly only can access static / global data; and interrupt handlers cannot easily be shared for different users. In particular, they have no void *refCon parameter, which many other callback based APIs offer.

So I am really curious to learn how you bypassed that problem. But please let's not put it onto this old, closed issue; instead, submit a pull request, and/or a new issue where you explain your changes.


You are receiving this because you commented.
Reply to this email directly or view it on GitHub

from rc-switch.

bilogic avatar bilogic commented on June 26, 2024

@fingolfin, @MeJIyA my codes and suggestions are on #63

from rc-switch.

Mshad0w avatar Mshad0w commented on June 26, 2024

hi,
great job...
as another hack ,if you include <PinChangeInt.h> library to RCSwitch.c,
and replace this line in RCSwitch::enableReceive() functon:
attachInterrupt(this->nReceiverInterrupt, handleInterrupt, CHANGE);
with :
attachPinChangeInterrupt(this->nReceiverInterrupt, handleInterrupt, CHANGE);
receive function can be attached to every other pins of board,by adding pin number in enableReceive(pin_number) routin...
useful for nodemcu , esp8266 and etc...

from rc-switch.

AKTanara avatar AKTanara commented on June 26, 2024

I solved this problem by simply duplicating the library with new name "RCSwitch2" and created the second receiver instance with that library. It worked perfectly. So if you are interested in this solution it is just enough to copy the library to another folder with name "RCSwitch2" and replace all "RCSwitch" phrases in the files with "RCSwitch2". This is most easily done by Notepad++ in few clicks.
2021-07-20_190125
2021-07-20_190520
ATTENTION: Just be careful not to have main library files open in Notepad++ otherwise it would replace instances of the word in those files too.
PS: If this issue is solved by just duplicating the library for the second instance of receiver, it has nothing to do with hardware limitations of handling interrupt pins and it is all about misuse of STATIC variables and definitions:
2021-07-20_191724
PS2: Probably the culprits are these three static variables defined in handleInterrupt() method:
2021-08-12_180229

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.