Rc5Renderer - infraRed4Arduino issue?

Hello All,

I'm trying to build a device that's sending a sequence of infrared comments to a device, the device uses RC5 infrared commando's for different setups.

After some searcing i finally found a piece of code that works.

The Rc5 Renderer example that comes with the infraRed4Arduino library.

However, even if i let the code untouched and run continuesly , it goes perfectly well untit it reaches 21 counts.

The first 20 times it perfectly sends a "1"

At number 21 the LED starts flickereing in a very fast pattern (i used a red LED for testing.)

This is the demo code,.

// Sends Rc5 0/1 twice with different toggle values.
// Turns e.g. a Philips TV to channel 11.

#include <Rc5Renderer.h>
#include <IrSenderPwm.h>

IrSender *sender;

void setup() {
    sender = IrSenderPwm::getInstance(true);
}

void loop() {
    const IrSignal *signal = Rc5Renderer::newIrSignal(0, 1);
    sender->sendIrSignal(*signal);
    delay(1000);
    signal = Rc5Renderer::newIrSignal(0, 1);
    sender->sendIrSignal(*signal);
    delay(1000);
}

I hope someone has some advice.

Thank you

Memory leak? You don't release that memory in your code.

Unfortunately that ultimately bad code is provided as an example in the library. I have serious doubts about the quality of the whole library if such code is provided as an example.

Hello pylon,

Sorry for my late response, do you know any good example i can use?

So far the RC5 exapmples doesnt seem to work properly.
I think it has something to to with the toggle bit.

This was the first piece of code i found that could send multiple characters that were accepted by the receiving end.
Well until i got to 20.

Thanks,

Johan

No.

Did you understand my previous post? Do you know what a memory leak is?

Probably because after 20 rounds (or even earlier) you ran out of memory.

Well if i'm correct the memory gets flooded at some point with a memory leak, but i'm nowhere near a point where i can look at a piece of code and see that it's a memory problem.

But looking back at your anwser again.

That line of code you mentioned probably fills the memory with a generated Irsignal.
And with not releasing (probably deleting in noob terms) the memory i flood the memory since it's filling the memory with a new generated signal each time.

So i need to find a way to delete/release that piece of memory.

I already told you the memory leak. In the example code you call

Rc5Renderer::newIrSignal

twice which returns a newly allocated object but that object is not freed in the code. That's why most modern libraries doesn't return object pointers but references. You've chosen another library so you're responsible for the memory management.

The operator is called "delete". That should help to find the documentation on the Internet.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.