From 68b9f4845049d90949deb3eb7eeefacdfae170fe Mon Sep 17 00:00:00 2001 From: rudolfkoenig Date: Sat, 29 Jan 2011 16:41:57 +0000 Subject: [PATCH] Code by B.M. git-svn-id: https://svn.fhem.de/fhem/trunk@816 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/00_LIRC.pm | 30 ++++++++--- fhem/docs/commandref.html | 105 ++++++++++++++++++++++++++++---------- 2 files changed, 102 insertions(+), 33 deletions(-) diff --git a/fhem/FHEM/00_LIRC.pm b/fhem/FHEM/00_LIRC.pm index 6d7355759..4fcebcefe 100644 --- a/fhem/FHEM/00_LIRC.pm +++ b/fhem/FHEM/00_LIRC.pm @@ -17,6 +17,7 @@ LIRC_Initialize($) # Provider $hash->{ReadFn} = "LIRC_Read"; + $hash->{ReadyFn} = "LIRC_Ready"; $hash->{Clients} = ":LIRC:"; # Consumer @@ -33,13 +34,14 @@ LIRC_Define($$) $hash->{STATE} = "Initialized"; + $hash->{LircObj}->clean_up() if($hash->{LircObj}); delete $hash->{LircObj}; delete $hash->{FD}; my $name = $a[0]; my $config = $a[2]; - Log 3, "LIRC opening LIRC device $config"; + Log 3, "LIRC opening $name device $config"; my $lirc = Lirc::Client->new({ prog => 'fhem', rcfile => "$config", @@ -53,9 +55,11 @@ LIRC_Define($$) $select->add( $lirc->sock ); $hash->{LircObj} = $lirc; - $hash->{FD} = $lirc->sock; - $selectlist{"$name.$config"} = $hash; - $hash->{SelectObj} = $select; + + $hash->{FD} = $lirc->{sock}; # is not working and sets timeout to undefined + $selectlist{"$name"} = $hash; # + $readyfnlist{"$name"} = $hash; # thats why we start polling + $hash->{SelectObj} = $select; $hash->{DeviceName} = $name; $hash->{STATE} = "Opened"; @@ -68,7 +72,10 @@ LIRC_Undef($$) { my ($hash, $arg) = @_; - $hash->{LircObj}->close() if($hash->{LircObj}); + $hash->{LircObj}->clean_up() if($hash->{LircObj}); + delete $hash->{LircObj}; + delete $hash->{FD}; + return undef; } @@ -85,11 +92,22 @@ LIRC_Read($) # an ir event has been received (if you are tracking other filehandles, you need to make sure it is lirc) my @codes = $lirc->next_codes; # should not block for my $code (@codes){ - Log 3, "LIRC code: $code\n"; + Log 3, "LIRC $code toggle"; DoTrigger($code, "toggle"); } } } +##################################### +sub +LIRC_Ready($) +{ + my ($hash) = @_; + + my $select= $hash->{SelectObj}; + + return $select->can_read(0); +} + 1; diff --git a/fhem/docs/commandref.html b/fhem/docs/commandref.html index bf5fb629b..d57f601e9 100644 --- a/fhem/docs/commandref.html +++ b/fhem/docs/commandref.html @@ -2233,51 +2233,64 @@ A line ending with \ will be concatenated with the next one, so long lines
Set +
+ + Debugging: +
@@ -3054,12 +3085,32 @@ A line ending with \ will be concatenated with the next one, so long lines

LIRC