Once again: Emulating prolonged button presses

The place where software developers meet

Moderator: marcus

Once again: Emulating prolonged button presses

Postby Uli Zappe » Sun 17. Feb 2013, 00:16

Hi everyone,

this topic was already discussed several times, but not sufficiently for my needs, so I have to bring it up again.

Here is my situation: I own an IRTrans Ethernet Module and need to control the motor zoom of a projector by a Linux command line utility. With the IR remote control of the projector, controlling the zoom is done by pressing + and – buttons for prolonged periods of time. In IRTrans, I cannot "simulate" this action by simply repeating short button presses fast, as this does not result in smooth motor movement and would destroy the motor rather sooner than later. Instead, I need to exactly reproduce the behavior of the original IR remote control.

I had been told by IRTrans' Sales & Marketing that this could be difficult, but in fact, the first step of making IRTrans perform in the desired way via the GUI control application turned out to be as simple as possible.

My desktop computers are all Macs, so I was using iRed. In iRed, I simply had to learn the Basic code and the Repeat code and set the Repeat time to 100 ms. Then, when pressing the Test button in iRed's Action Editor for a prolonged period of time, everything worked perfectly.

So, from iRed I know that my task can be done with IRTrans. My problem is the second step: to make this functionality available via a command line utility on my Linux home server.

From within iRed, I flashed my learned codes to the IRTrans EPROM.

While IRTrans comes with a Linux ASCII command line utility, this command line utility is obviously unable to emulate prolonged button presses. (I wonder why …)

So it seems I will have to write my own utility. I thought that this would be no big deal, but my first trial, a simple Perl test implementation, failed badly: Using the TCP/IP ASCII interface as described in the TCP/IP ASCII interface Protocol guide, I established a TCP/IP ASCII connection and sent Asnd and Asndr commands in 100 ms periods. (I tried an implementation with first sending Asnd and then Asndr repeatedly, as well as only sending Asndr repeatedly – what would be the correct way?)

However, as a result, the motor zoom behaves as if I was pressing the IR remote control button repeatedly – exactly the behavior I need to avoid. :(

So, the question is: What exactly does iRed do when I press its Test button for a longer period of time, and how can I do this myself in my command line utility? Obviously, using the TCP/IP ASCII interface and sending Asndr repeatedly is not the way to do it – but what is?

I'm completely at a loss here and would be very grateful for any information, code samples etc.

TIA!

Uli
Uli Zappe
 
Posts: 17
Joined: Sun 3. Feb 2013, 14:20

Re: Once again: Emulating prolonged button presses

Postby eric » Thu 21. Feb 2013, 17:28

Hi Uli,

I'm having a little trouble helping you here: I do not know what iRed does when the "Test" button is pressed continuously. You will have to ask Robert (the iRed developer) about this.

I don't know how long the IR codes are - maybe they are longer than 100ms. In this case issuing the next code while the IRTrans is still busy sending the first code is not a good idea. So please find out how long it takes to send one code sample and adjust the timing accordingly. You will have to analyse the .rem file with the codes.

regards,

Eric
eric
Administrator
 
Posts: 157
Joined: Mon 22. Oct 2012, 10:05

Re: Once again: Emulating prolonged button presses

Postby IRTrans » Thu 21. Feb 2013, 22:10

Hi,
in general there are a few things to consider here.

1. You will need to take care that you send the IR Codes in the correct timing. The easiest way would be to wait until the ACK comes back via UDP or TCP and then send the next code. If you send the next code to early it might not be sent and that causes delays.
2. For most codes it does not make a difference if you send standard or repeat codes. If you want to use specific repeat codes you need to learn them first.
3. The best would be to learn the IR Codes using the windows SW. Then you can send/post the IR Codes and we can tell you if there are repeat codes.
4. Maybe sending the codes through the irserver is faster than via the internal IRDB, however we will need to see how it is done.

In general it will surely be possible to send the codes as fast as iRed does, however that might need a bit of fine tuning.

IRTrans
IRTrans
Administrator
 
Posts: 2115
Joined: Mon 21. Apr 2008, 23:32

Re: Once again: Emulating prolonged button presses

Postby Uli Zappe » Fri 22. Feb 2013, 05:48

Hi,

eric wrote:I don't know how long the IR codes are - maybe they are longer than 100ms. In this case issuing the next code while the IRTrans is still busy sending the first code is not a good idea. So please find out how long it takes to send one code sample and adjust the timing accordingly. You will have to analyse the .rem file with the codes.

Well, there are no .rem files with iRed (at least not that I know), but I guess the xml files of iRed will also do.

Frankly, I'm not really sure how the IRTrans command bit sequence maps to the timing – there are much more bits than there are pulse/pause pairs in the corresponding timing. Therefore, I don't really know how to find out the time that one command takes.

Here is one command from iRed:

Regular code:
Code: Select all
[N]4[1]496 520[2]496 1000[3]496 2592[4]496 39488[RC]1[RP]0[FREQ]31[D]2000000000320100000000

Repeat code:
Code: Select all
[N]3[1]488 2592[2]496 512[3]504 1000[RC]1[RP]0[FREQ]31[SB][D]S0100000000

(Actually, this command isn't for my projector, but for the volume of my audio amplifier, which has exactly the same issues, but can't be damaged by testing and, since it uses a loud clicking relay for volume control, makes it very obvious whether things work as they should.)

And for what it's worth, here is the Perl program I used for testing. It's extremely basic (a long button press is invoked by kino <command> r and needs to be cancelled by Ctrl-C); I just wrote it to find out if things work at all the way I expected – maybe it's too basic in some aspect that I don't see?

Code: Select all
#!/usr/bin/perl -w

use IO::Socket;
use Time::HiRes  qw(usleep);

if ($#ARGV < 0 || $#ARGV > 1)
{
   print "Usage: kino <command>  [r]\n"; exit -1;
}

$SOCK = new IO::Socket::INET (PeerAddr => 'ir', PeerPort => '21000', Proto => 'tcp');
die "Could not create socket: $!\n" unless $SOCK;

print $SOCK "ASCI";

$REPEAT = 0;
$REPEAT = 1 if ($#ARGV == 1 && $ARGV[1] eq "r");


if ($REPEAT)
{
   print $SOCK "Asnd kino-kino,$ARGV[0]\n";
   usleep 100000;
   while (1) {print $SOCK "Asndr kino-kino,$ARGV[0]\n"; usleep 100000;}
}
else
{
   print $SOCK "Asnd kino-kino,$ARGV[0]\n";
}

close($SOCK);




IRTrans wrote:1. You will need to take care that you send the IR Codes in the correct timing. The easiest way would be to wait until the ACK comes back via UDP or TCP and then send the next code. If you send the next code to early it might not be sent and that causes delays.

I have tried a myriad timing combination for the delay after the first/basic code and then the delay between the repeat codes, without any success. If the intervals are too short, it doesn't work at all (= volume changes one step only, as if the button was only pressed shortly), and as soon as they get long enough, they behave as several discrete button presses (= the repeat frequency of the steps (= relay clicks) is much lower than with a continuous button press in either the original remote control or iRed).

There seems to be no way to make the step frequency as fast with my Perl script as with a continuous button press in either the original remote control or iRed.

2. For most codes it does not make a difference if you send standard or repeat codes. If you want to use specific repeat codes you need to learn them first.

Repeat codes are definitely required for iRed to work correctly, for both my audio amplifier and my projector. Of course I learned them (otherwise iRed wouldn't work), and flashed all codes I learned to the IRTrans device.

Maybe something went wrong with the flashing for whatever reason? (Though it seems highly unlikely that the regular codes were flashed correctly, whereas the repeat codes were not.) Is there any way for me to control that?

3. The best would be to learn the IR Codes using the windows SW. Then you can send/post the IR Codes and we can tell you if there are repeat codes.

I could try to do that in a virtual machine. Are the IR codes from iRed somehow not as clear to understand?

In general it will surely be possible to send the codes as fast as iRed does

Yep, that's what one would think, and what I definitely hope for.

however that might need a bit of fine tuning.

But what could be possibly tuned except the repeat interval, where – as I wrote – I already tried many, many values? I wonder if it makes a difference that iRed somehow sends the commands directly to the IRTrans (because it already worked before flashing the commands to the IRTrans device), whereas my Perl script uses the internally stored commands in the IRTrans device …

Uli
Uli Zappe
 
Posts: 17
Joined: Sun 3. Feb 2013, 14:20

Re: Once again: Emulating prolonged button presses

Postby Uli Zappe » Fri 22. Feb 2013, 20:09

I have now installed IRTrans on a virtual Windows Vista installation and learned the same command as with the iRed example in my last post. Here is the resulting .rem file:

Code: Select all
[REMOTE]
  [NAME]test
 
[TIMING]
  [0][N]4[1]496 520[2]496 1000[3]496 2592[4]496 39488[RC]1[RP]0[FREQ]31[FREQ-MEAS]
  [1][N]3[1]496 2592[2]496 512[3]496 1008[RC]1[RP]0[FREQ]31[FREQ-MEAS][SB]
 
[COMMANDS]
  [quieter][T]0[D]2000000000320100000000
  [quieter@][T]1[D]S0100000000


So apart from the different notation, the basic code is identical, and the repeat code differs only slightly with regard to its timing.

I also wanted to try if the long button press works with the Windows GUI client as it does with iRed, but unfortunately, I'm too stupid for Windows. Contrary to the manual, the GUI client opened without any template remote layout (although C:\ProgramData\IRTrans\remote.irm does exist and looks correct), and I found no way to fix that. Sending the command via the Send menu of the GUI client, on the other hand, obviously only triggers the send action when the button is released by the mouse, so prolonged button presses cannot be tested by design. (Sending did work for both quieter and quieter@ as far as a short button press (= 1 discrete step only in the volume control) is concerned.)

I'm not sure if any of this provides any additional important information.

Uli
Uli Zappe
 
Posts: 17
Joined: Sun 3. Feb 2013, 14:20

Re: Once again: Emulating prolonged button presses

Postby IRTrans » Sat 23. Feb 2013, 13:58

The old GUI Client irremote.exe has been replaced by the new GUI Client. It is, however, still part of the Windows SW Distribution.
Simply start irremote.exe or (via the Start Menu) IRTrans Virtual remote.

BTW: There are new IRTrans SW Manuals available for download from our website. They describe the current SW.

IRTrans
IRTrans
Administrator
 
Posts: 2115
Joined: Mon 21. Apr 2008, 23:32

Re: Once again: Emulating prolonged button presses

Postby Uli Zappe » Sun 24. Feb 2013, 06:25

IRTrans wrote:The old GUI Client irremote.exe has been replaced by the new GUI Client. […] Simply start irremote.exe or (via the Start Menu) IRTrans Virtual remote.

Ah, that did it! :)

However, it doesn't get me much further. :(

First, contrary to iRed, the Windows software creates two separate commands for the regular code and the repeat code (in my case, quieter and quieter@).

I would have thought that in case of a prolonged button press, (1.) the regular code has to be sent once and then (2.) the repeat code has to be sent repeatedly as long as the button is pressed.

Is this assumption correct?

And if so, then how do I link both commands to the same virtual remote button in remote.irm? (I don't want to have an extra button for a prolonged press, of course.)


Second, for this test, I linked both quieter and quieter@ to different buttons in the virtual remote, to be able to at least try both codes for themselves. However, none of them works correctly; they both display the same, faulty behavior for long button presses: The volume gets 2 steps quieter (= 2 relay clicks) at the start of the button press, and then nothing further happens, no matter how long I keep pressing the button. (Pressing one of the two buttons shortly correctly makes for 1 step down.)


So the question is, how do I get repeated commands to work in the Windows GUI client?

One point that comes to my mind: in iRed's Action Editor, where you learn and fine tune codes, I can specify a Repeat Time for repeated commands. This value turned out to be relatively critical in my case; it has to be between 85 and 115 ms for iRed to work correctly.

However, I could not find a comparable setting in the Windows software at all. Did I overlook something or how do I handle this in Windows?

Uli
Uli Zappe
 
Posts: 17
Joined: Sun 3. Feb 2013, 14:20

Re: Once again: Emulating prolonged button presses

Postby IRTrans » Sun 24. Feb 2013, 18:46

Hi,
the Windows SW automatically uses the repeat command for repeated codes. They just need to have the same name (e.g. quieter and quieter@).
The Windows SW is not as sophisticated as the Mac SW, therefore there is no repeat timer.

When sending from your own application on LINUX you might need to do some testing with delays, too.

It might be helpfull to use a network monitor SW so that you can see the exact resulting timing.

IRTrans
IRTrans
Administrator
 
Posts: 2115
Joined: Mon 21. Apr 2008, 23:32

Re: Once again: Emulating prolonged button presses

Postby Uli Zappe » Mon 25. Feb 2013, 04:07

IRTrans wrote:the Windows SW automatically uses the repeat command for repeated codes. They just need to have the same name (e.g. quieter and quieter@).

I see. There was nothing about this in the documentation.

What about Linux? I.e. what do I do when I want to send this repeat code with either the ASCII client or the Shared Library functions?

irclient <ip> <remote> quieter@ produces a Remote Command not found error.

The Shared Library I couldn't test yet as its source is defective (see below).

The Windows SW is not as sophisticated as the Mac SW, therefore there is no repeat timer.

Are you saying that for prolonged button presses, there are no continuing (= more than one) repeats at all in the Windows software, or only that the timing of these repeats cannot be set by the user (if the latter, what is the fixed timing?)?

Because if there is only one repeat code, it's no wonder I cannot test prolonged button presses in Windows …

When sending from your own application on LINUX you might need to do some testing with delays, too.

It might be helpfull to use a network monitor SW so that you can see the exact resulting timing.

I have now tcpdump'd the iRed communication and this is what I found:

1. iRed uses UDP, not TCP/IP.

2. The timing is precisely regular command – 130 ms – repeat command – 100 ms – repeat command – 100 ms – … (100 ms was the interval I specified).

When I reproduce this timing with my Perl script, it does not work.

Before drawing other conclusions, this could be because from what I can see when tcpdumping my Perl script, the Perl script seems to produce a much less stable timing for whatever reason.

Therefore, I first want to try to reimplement this in C with the IRTrans Shared Library. Unfortunately, the currently downloadable archive is incomplete; IRTransDLL.c is missing, so the library doesn't compile.

So could you please upload a complete version of the IRTrans Shared Library source (and, as already asked above, tell me how to send the repeat code with the library – quieter@ or something else?).

Thanks

Uli
Uli Zappe
 
Posts: 17
Joined: Sun 3. Feb 2013, 14:20

Re: Once again: Emulating prolonged button presses

Postby eric » Mon 25. Feb 2013, 17:03

Hi Uli,

since it seems to work using iRed I suppose the issue is with the timing of commands. Try to reproduce this. To send the repeat command you might have to rename it in the .rem file (remove the "@"). Then you will be able to access it directly.

another suggestion: Did you try using iRed as a IRServer? What I'm thinking about is: What happens if you use the ASCII API to tell iRed to send commands. iRed running on your PC will be much faster looking up the IR Code in the library than the IRTrans which has to search its internal flash memory. I don't know which version of our IRServer is used in the current iRed but I think its worth a try.

Eric
eric
Administrator
 
Posts: 157
Joined: Mon 22. Oct 2012, 10:05

Next

Return to APIs

Who is online

Users browsing this forum: No registered users and 7 guests

cron