Active Topics

 



Notices


Reply
Thread Tools
Posts: 29 | Thanked: 7 times | Joined on May 2007
#21
Originally Posted by LukeD View Post
Ok I hadn't actually installed Irreco on my n800 before writing the above, but I just did so and I have to say this is pretty awesome. Fantastic work!

What's involved with writing more back-end control modules? I might take a stab at a Girder interface if you're interested.
The API you need to implement is here: https://garage.maemo.org/plugins/scm...co&view=markup

You should probably pull irreco sources from svn and take a look at /irreco/trunk/backends/. You can probably just make a copy of some pre-exising backend and replace old stuff with girder stuff.

Also you need to install Maemo development enviroment, if you dont have it already.

Last edited by eXeonical; 2008-02-27 at 08:06.
 
Posts: 11 | Thanked: 2 times | Joined on Jan 2006
#22
Awesome, I'll grab the source this weekend and take a look.
 
emjayes's Avatar
Posts: 121 | Thanked: 163 times | Joined on Feb 2008 @ Oulu, Finland
#23
After trying out irreco, which I find amazing, I started wondering if it could be used as a total remote controller for a Linux PC.

I quickly discovered that a real lirc daemon is not the tool to use, since it only sends the commands through infrared transmitter and does not notify local clients at all.

After a bit of studying of how to communicate with lirc daemon, I hacked together a lircd emulator to run linux commands for each keypress of the irreco remote.

This is a quick and most likely _very_ dirty hack, since it's the first ever perl script that I have made.

try it out and let me know what you think.

By default it emulates a lirc daemon in port 9999 and listens to all interfaces. Change that if necessary, in the configuration file that is automatically created the first time you run the script.

Code:
#!/usr/bin/perl
#lirc daemon emulator for using irreco to remote control your mythfrontend by emulating a real lirc daemon but instead of transmitting infrared signals
#the button presses are mapped to system() commands as per instrucions in the configuration file
#this is my very first Perl script ever, so everything could probably be done much better, but hey, at least it works as expected.
#Mika Saarela emjayes@gmail.com 28.02.2008
#Thank you Arto Karppinen et al for creating such a great piece of software for Internet tablet users.
use IO::Socket;
use IO::Select;
use Sys::Hostname;
eval "require(Proc::Daemon)";
die "Proc::Daemon not installed \nrun:\nsudo apt-get install libproc-daemon-perl\nor:\ncpan install Proc::Daemon\nto install\n" if $@;
use Proc::Daemon;
my $host = hostname();
my @keys = ();
my @actions = ();
my $numkeys = ();
my $keynum = ();
if (grep /^-h|^--help/, @ARGV){{print "\nUsage: $0 [option]\n\t\t\t--nodaemon\tdo not daemonize\n\t\t\t--stop\t\tstop the running lircdemulator\n";}{exit}}
if (grep /^--stop/, @ARGV){{print "Stopping running lircd emulator\n";}{system("killall lircdemulator>/dev/null 2>&1")}}
if (! -e "$ENV{ HOME }/.lircdemulator"){
{print "Configuration file  $ENV{ HOME }/.lircdemulator does not exist, creating a sample configuration file.\n\nEdit it to match your needs and run again\n"};
{open(CREATECONFIG, "> $ENV{ HOME }/.lircdemulator") or die "Unable to write example configuration to  $ENV{ HOME }/.lircdemulator\n";}
{print CREATECONFIG "#The format of the configfile is:\n#keyname action\n#for example:\n#button_name echo <any command with parameters and redirection etc. that you can run from the command line>\n
#Configure the IPADDR if you do not wish to listen on all interfaces\nIPADDR=0.0.0.0\n#Configure the port you want to listen to. Do not use 8765 if you also have a real lirc daemon running\nPORT=9999\n
#here are some working samples if you have mythfrontend installed with Network Remote Control interface enabled.\nmyth_up echo key up|nc -q0 localhost 6546\nmyth_down echo key down|nc -q0 localhost 6546
myth_right echo key right|nc -q0 localhost 6546\nmyth_left echo key left|nc -q0 localhost 6546\nmyth_escape echo key escape|nc -q0 localhost 6546\nmyth_menu echo key m|nc -q0 localhost 6546
myth_volup echo key f11|nc -q0 localhost 6546\nmyth_voldown echo key f10|nc -q0 localhost 6546\neject eject\nclose_drive eject -t\n
#the whole line minus keyname is called as system(&) when corresponding key is pressed in irreco interface.
#the config file is read at start only, You will need to restart the emulator if the config file is modified";}
{close(CREATECONFIG);}
{die "lircd emulator not started.\n"};}

open(CONFIG, "< $ENV{ HOME }/.lircdemulator" ) or die "Unable to open configuration file\n"; #open the configuration file 
        while (<CONFIG>){
        if (grep /PORT/, $_ ) {{s/\s*//g;}{chomp ($port=substr($_,5))}{$_=""};}
        if (grep /IPADDR/, $_ ) {{s/\s*//g;}{chomp ($ipaddr=substr($_,7))}{$_=""};}
        s/^#.*//; #ignore comment lines
        s/^\s+//; #ignore leading blank
        chomp; #remove linefeeds
        unless ($_ =~ /^()$/) {push (@actions,"$_ &\n")}; #push valid commands to @actions appending & so the execution will return without delay
        s/\s*(\w+).*/$1/; #strip to the keyname
        unless ($_ =~ /^()$/) {$keynum = $keynum +1,$numkeys = push (@keys,"$keynum $_\n")}; #push valid keys to @keys
        };
close(CONFIG); #close the configuration file
if (! system("echo ping|nc -q0 $ipaddr $port>/dev/null 2>&1")){{print "Port $port already in use\n";}{exit}}  
print "lircd emulator listening on $ipaddr:$port\n";
if (! grep /^--nodaemon/, @ARGV) {Proc::Daemon::Init;} #daemonize the script if --nodaemon was not passed
while (forever){ #run until explicitly killed 
my $sock = new IO::Socket::INET( #create a network socket to listen to
LocalHost => $ipaddr, #listen on all interfaces, alter if needed
LocalPort => $port, #do not use 8765 if you have a real lir daemon running as well
Proto => 'tcp',
Listen => 1,
Reuse => 1,
);
die "Could not create Socket: $!\n" unless $sock; #die if the port or address is already used
my $new_sock = $sock->accept();
        while(<$new_sock>) {
                print "Client requested $_";
                if (/^LIST$/){ #the client requests the number and names of remotes available. We have just 1, named <your hostname>
                print $new_sock "BEGIN\nLIST\nSUCCESS\nDATA\n1\n$host\nEND\n"; #reply to the client
                }
                if (/^LIST $host$/){ #the client requests the available "buttons"
                        print $new_sock "BEGIN\nLIST $host\nSUCCESS\nDATA\n",$numkeys,"\n",@keys,"END\n"; #send the available buttons
                }
                if (/^SEND_ONCE $host\ /){ #client has pressed a button 
                        {$strip=(length ("SEND_ONCE $host "))}; #calculate the length of characters to be stipped
                        {$string = substr($_,0,$strip)=""}; #remove SEND_ONCE $host from $_ and save that to $string 
                        {@action = grep(/^$string*\b/, @actions)}; #get the line containing the button pressed from available actions
                        chomp $string; #remove linefeed from the string
                        {$key = $_}; #set the key to match the button pressed so we can use it in the reply
                        {$action = substr((join " ", @action),(length("$string")+1))}; #create a command string from the array
                        {print $new_sock  "BEGIN\n\SEND_ONCE ",$host," ",$key,"SUCCESS\nEND\n"}; #reply client  
                        system("$action"); #run the command 
                        chomp $action;
                        print "Running system(\"$action\")\n";
                }
        close($new_sock)}; #close the socket and start waiting for a new connection
};
 
emjayes's Avatar
Posts: 121 | Thanked: 163 times | Joined on Feb 2008 @ Oulu, Finland
#24
Forgot to say:

save the above code as lircdemulator and chmod +x to make it executable.
 
Posts: 551 | Thanked: 46 times | Joined on Oct 2007
#25
eXeonical,

Way cool.
In a few minutes I create scifi buttons. Now need to figure out how to connect to my equipment.
I second, third, fourth etc... to have portrait and landscape modes with a slider on the side so we could add lots more buttons.
Keep developing this app. It is one of the slickest I've loaded.
Thanks,

Dan
 
Posts: 29 | Thanked: 7 times | Joined on May 2007
#26
Originally Posted by emjayes View Post
After trying out irreco, which I find amazing, I started wondering if it could be used as a total remote controller for a Linux PC.

I quickly discovered that a real lirc daemon is not the tool to use, since it only sends the commands through infrared transmitter and does not notify local clients at all.

After a bit of studying of how to communicate with lirc daemon, I hacked together a lircd emulator to run linux commands for each keypress of the irreco remote.
Thats pretty cool.

I have always thought that it would be nice to control Linux PC with irreco, what i had in mind was writing SSH commandline backend for irrco, but i never got the time
 
Posts: 29 | Thanked: 7 times | Joined on May 2007
#27
 
Posts: 29 | Thanked: 7 times | Joined on May 2007
#28
Originally Posted by LukeD View Post
Awesome, I'll grab the source this weekend and take a look.
If been trying to reply to your email, but i dont think the Internet Tablet Talk email sendin system works for you. Do you have correct email set to your profile?

Anyways, you can test Irreco with the scripts i have written. I added instructions to the README file.

https://garage.maemo.org/plugins/scm...co&view=markup
 
Posts: 2 | Thanked: 0 times | Joined on Nov 2006
#29
Hi,

Great work

What about implementing the full button set for MythTV? Buttons like pause, play, stop, Recordings, TV etc would be very nice

Best regards: Gerolf
 
Posts: 18 | Thanked: 0 times | Joined on Jan 2008 @ The Peg
#30
Is there any possibility of just using a simple 3.0mm jack to ir transciever. I have one lying around, and would love to just plug it in and control my tv. Could someone shine some light on my idea? Does it have to be so expensive and difficult to control a tv?
 
Reply


 
Forum Jump


All times are GMT. The time now is 00:27.