2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-03-04 17:36:39 +00:00

00_ZWDongle.pm: recursive read problems (Patch by gero, Forum #37418)

git-svn-id: https://svn.fhem.de/fhem/trunk@8626 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig 2015-05-24 11:42:38 +00:00
parent 8fe0fc16e3
commit 88e3f85001
2 changed files with 11 additions and 8 deletions

View File

@ -496,14 +496,13 @@ ZWDongle_Read($@)
# buffer after a timeout is my only idea of solving this problem. # buffer after a timeout is my only idea of solving this problem.
my $ts = gettimeofday(); my $ts = gettimeofday();
my $data = ($hash->{ReadTime} && $ts-$hash->{ReadTime} > 1) ? my $data = ($hash->{ReadTime} && $ts-$hash->{ReadTime} > 1) ?
"" : $hash->{PARTIAL}; $buf : $hash->{PARTIAL}.$buf;
$hash->{ReadTime} = $ts; # Flush old data. $hash->{ReadTime} = $ts;
Log3 $name, 5, "ZWDongle/RAW: $data/$buf"; Log3 $name, 5, "ZWDongle RAW buffer: $data";
$data .= $buf;
my $msg; my $msg;
while(length($data) > 0) { while(length($data) > 0) {
my $fb = substr($data, 0, 2); my $fb = substr($data, 0, 2);
@ -547,6 +546,7 @@ ZWDongle_Read($@)
"$name: wrong checksum: received $rcs, computed $ccs for $len$msg"; "$name: wrong checksum: received $rcs, computed $ccs for $len$msg";
DevIo_SimpleWrite($hash, "15", 1) # Send NACK DevIo_SimpleWrite($hash, "15", 1) # Send NACK
if(++$hash->{nrNAck} < 5); if(++$hash->{nrNAck} < 5);
$msg = undef;
next; next;
} }
$hash->{nrNAck} = 0; $hash->{nrNAck} = 0;
@ -554,7 +554,9 @@ ZWDongle_Read($@)
Log3 $name, 5, "ZWDongle_Read $name: $msg"; Log3 $name, 5, "ZWDongle_Read $name: $msg";
last if(defined($local) && (!defined($regexp) || ($msg =~ m/$regexp/))); last if(defined($local) && (!defined($regexp) || ($msg =~ m/$regexp/)));
$hash->{PARTIAL} = $data; # Recursive call by ZWave get, Forum #37418
ZWDongle_Parse($hash, $name, $msg); ZWDongle_Parse($hash, $name, $msg);
$data = $hash->{PARTIAL};
$msg = undef; $msg = undef;
} }
@ -572,6 +574,7 @@ ZWDongle_ReadAnswer($$$)
return ("No FD (dummy device?)", undef) return ("No FD (dummy device?)", undef)
if(!$hash || ($^O !~ /Win/ && !defined($hash->{FD}))); if(!$hash || ($^O !~ /Win/ && !defined($hash->{FD})));
my $to = ($hash->{RA_Timeout} ? $hash->{RA_Timeout} : 3); my $to = ($hash->{RA_Timeout} ? $hash->{RA_Timeout} : 3);
Log3 $hash, 4, "ZWDongle_ReadAnswer arg:$arg regexp:$regexp";
for(;;) { for(;;) {

View File

@ -272,9 +272,9 @@ my %zwave_class = (
wakeupIntervalCapabilities => "09" }, wakeupIntervalCapabilities => "09" },
parse => { "028407" => 'wakeup:notification', parse => { "028407" => 'wakeup:notification',
"..8406(......)(..)" => "..8406(......)(..)" =>
'"wakeupReport:interval ".hex($1)." target ".hex($2)', '"wakeupReport:interval ".hex($1)." target ".hex($2)',
"..840a(......)(......)(......)(......)" => "..840a(......)(......)(......)(......)" =>
'"wakeupIntervalCapabilitiesReport:min ".hex($1).'. '"wakeupIntervalCapabilitiesReport:min ".hex($1).'.
'" max ".hex($2)." default ".hex($3)." step ".hex($4)' '" max ".hex($2)." default ".hex($3)." step ".hex($4)'
} }, } },
ASSOCIATION => { id => '85', ASSOCIATION => { id => '85',
@ -617,7 +617,7 @@ ZWave_Cmd($$@)
no strict "refs"; no strict "refs";
my $iohash = $hash->{IODev}; my $iohash = $hash->{IODev};
my $fn = $modules{$iohash->{TYPE}}{ReadAnswerFn}; my $fn = $modules{$iohash->{TYPE}}{ReadAnswerFn};
my ($err, $data) = &{$fn}($iohash, $cmd, "^000400$id") if($fn); my ($err, $data) = &{$fn}($iohash, $cmd, "^000400${id}..$cmdId") if($fn);
use strict "refs"; use strict "refs";
return $err if($err); return $err if($err);