From e99e00c8f992804457dba89dfab2f3bcdf72b551 Mon Sep 17 00:00:00 2001 From: tpoitzsch Date: Sat, 10 Jan 2015 18:25:23 +0000 Subject: [PATCH] FRITZBOX: now with specific telnet prompt git-svn-id: https://svn.fhem.de/fhem/trunk@7500 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/72_FRITZBOX.pm | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/fhem/FHEM/72_FRITZBOX.pm b/fhem/FHEM/72_FRITZBOX.pm index 2035d0b59..93815675d 100644 --- a/fhem/FHEM/72_FRITZBOX.pm +++ b/fhem/FHEM/72_FRITZBOX.pm @@ -872,7 +872,10 @@ sub FRITZBOX_Readout_Aborted($) { my ($hash) = @_; delete($hash->{helper}{READOUT_RUNNING_PID}); - FRITZBOX_Log $hash, 1, "Timeout when reading Fritz!Box data."; + my $msg = "Error: Timeout when reading Fritz!Box data."; + readingsSingleUpdate($hash, "lastReadout", $msg, 1); + readingsSingleUpdate($hash, "state", $msg, 1); + FRITZBOX_Log $hash, 1, $msg; } ########################################## @@ -1791,7 +1794,10 @@ sub FRITZBOX_Open_Connection($) $telnet = undef; return $msg; } - + $telnet->prompt('/ $/'); + $telnet->cmd("PS1=' '"); + $telnet->buffer_empty; + return undef; } # end FRITZBOX_Open_Connection @@ -1872,15 +1878,13 @@ FRITZBOX_Exec_Remote($$) foreach (@{$cmd}) { - FRITZBOX_Log $hash, 5, "Execute '".$_."'"; + FRITZBOX_Log $hash, 5, "Execute '$_'"; unless ($_ =~ /^sleep/) { - @output=$telnet->cmd($_.";echo ' |#|'"); - $result = $output[0]; + @output=$telnet->cmd($_); + $result = $output[0] || ""; chomp $result; - $result = "" if $result eq " |#|"; - my $log = join " ", @output; - $log =~ s/\s*\|#\|\n//; + my $log = join "", @output; chomp $log; FRITZBOX_Log $hash, 5, "Result '$log'"; }