mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-04-07 12:58:13 +00:00
10_ZWave.pm/00_ZWDongle.pm: processSendStack tuning (Forum #50090)
git-svn-id: https://svn.fhem.de/fhem/trunk@11038 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
4bfde47752
commit
f73ef371ef
@ -405,6 +405,7 @@ ZWDongle_shiftSendStack($$$$)
|
|||||||
$hash->{WaitForAck}=0;
|
$hash->{WaitForAck}=0;
|
||||||
$hash->{SendRetries}=0;
|
$hash->{SendRetries}=0;
|
||||||
$hash->{MaxSendRetries}=3;
|
$hash->{MaxSendRetries}=3;
|
||||||
|
delete($hash->{GotCAN});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -450,6 +451,7 @@ ZWDongle_ProcessSendStack($)
|
|||||||
DevIo_SimpleWrite($hash, $msg, 1);
|
DevIo_SimpleWrite($hash, $msg, 1);
|
||||||
$hash->{WaitForAck} = 1;
|
$hash->{WaitForAck} = 1;
|
||||||
$hash->{SendTime} = $ts;
|
$hash->{SendTime} = $ts;
|
||||||
|
delete($hash->{GotCAN});
|
||||||
|
|
||||||
InternalTimer($ts+1, "ZWDongle_ProcessSendStack", $hash, 0);
|
InternalTimer($ts+1, "ZWDongle_ProcessSendStack", $hash, 0);
|
||||||
}
|
}
|
||||||
@ -500,6 +502,7 @@ ZWDongle_Read($@)
|
|||||||
Log3 $name, 4, "ZWDongle_Read $name: CAN received";
|
Log3 $name, 4, "ZWDongle_Read $name: CAN received";
|
||||||
$hash->{MaxSendRetries}++ if($hash->{MaxSendRetries}<7);
|
$hash->{MaxSendRetries}++ if($hash->{MaxSendRetries}<7);
|
||||||
$data = substr($data, 2);
|
$data = substr($data, 2);
|
||||||
|
$hash->{GotCAN} = 1;
|
||||||
if(!$init_done) { # InternalTimer wont work
|
if(!$init_done) { # InternalTimer wont work
|
||||||
$hash->{WaitForAck} = 0;
|
$hash->{WaitForAck} = 0;
|
||||||
$hash->{SendRetries}++;
|
$hash->{SendRetries}++;
|
||||||
@ -539,7 +542,7 @@ ZWDongle_Read($@)
|
|||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
$hash->{nrNAck} = 0;
|
$hash->{nrNAck} = 0;
|
||||||
Log3 $name, 4, "ZWDongle_Read $name: sending ACK, processing $msg";
|
Log3 $name, 4, "ZWDongle_Read $name: rcvd $msg, sending ACK";
|
||||||
DevIo_SimpleWrite($hash, "06", 1); # Send ACK
|
DevIo_SimpleWrite($hash, "06", 1); # Send ACK
|
||||||
ZWDongle_shiftSendStack($hash, 1, 5, "device ack reveived")
|
ZWDongle_shiftSendStack($hash, 1, 5, "device ack reveived")
|
||||||
if($msg =~ m/^0013/);
|
if($msg =~ m/^0013/);
|
||||||
@ -634,8 +637,8 @@ ZWDongle_Parse($$$)
|
|||||||
$hash->{"${name}_TIME"} = TimeNow();
|
$hash->{"${name}_TIME"} = TimeNow();
|
||||||
$hash->{RAWMSG} = $rmsg;
|
$hash->{RAWMSG} = $rmsg;
|
||||||
|
|
||||||
$hash->{SendTime} = 0 # Retry sending after a "real" msg from the dongle
|
$hash->{SendTime}-- # Retry sending after a "real" msg from the dongle
|
||||||
if($hash->{WaitForAck} && $rmsg !~ m/^(0113|0013)/);
|
if($hash->{GotCAN} && $rmsg !~ m/^(0113|0013)/);
|
||||||
|
|
||||||
my %addvals = (RAWMSG => $rmsg);
|
my %addvals = (RAWMSG => $rmsg);
|
||||||
|
|
||||||
|
@ -3549,7 +3549,7 @@ ZWave_isWakeUp($)
|
|||||||
# type is: set / sentset, get / sentget / sentackget
|
# type is: set / sentset, get / sentget / sentackget
|
||||||
# sentset will be discarded after ack, sentget needs ack (->sentackget) then msg
|
# sentset will be discarded after ack, sentget needs ack (->sentackget) then msg
|
||||||
# next discards either state.
|
# next discards either state.
|
||||||
# acktpye: next, ack or msg
|
# acktpye: retry, next, ack or msg
|
||||||
sub
|
sub
|
||||||
ZWave_processSendStack($$;$)
|
ZWave_processSendStack($$;$)
|
||||||
{
|
{
|
||||||
@ -3557,13 +3557,20 @@ ZWave_processSendStack($$;$)
|
|||||||
my $ss = $hash->{SendStack};
|
my $ss = $hash->{SendStack};
|
||||||
return if(!$ss);
|
return if(!$ss);
|
||||||
|
|
||||||
|
if($ackType eq "retry") {
|
||||||
|
$ss->[0] =~ m/^(.*)(set|get):(.*)$/;
|
||||||
|
$ss->[0] = "$2:$3";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if($ss->[0] =~ m/^sent(.*?):(.*)$/) {
|
if($ss->[0] =~ m/^sent(.*?):(.*)$/) {
|
||||||
if($1 eq "get" && $ackType eq "ack") {
|
my ($stype,$smsg) = ($1,$2);
|
||||||
$ss->[0] = "sentackget:$2";
|
if($stype =~ m/get/ && $ackType eq "ack") { # accept double-ACK
|
||||||
|
$ss->[0] = "sentackget:$smsg";
|
||||||
return;
|
return;
|
||||||
|
|
||||||
} elsif($1 eq "ackget" && $ackType eq "msg") {# compare answer class for get
|
} elsif($stype eq "ackget" && $ackType eq "msg") {# compare answer class
|
||||||
my $cs = substr($2, 6, 2);
|
my $cs = substr($smsg, 6, 2);
|
||||||
my $cg = substr($omsg, 2, 2);
|
my $cg = substr($omsg, 2, 2);
|
||||||
return if($cs ne $cg);
|
return if($cs ne $cg);
|
||||||
}
|
}
|
||||||
@ -3654,7 +3661,7 @@ ZWave_Parse($$@)
|
|||||||
readingsSingleUpdate($hash, "SEND_DATA", "failed:$arg", 1);
|
readingsSingleUpdate($hash, "SEND_DATA", "failed:$arg", 1);
|
||||||
$arg = "transmit queue overflow" if($arg == 0);
|
$arg = "transmit queue overflow" if($arg == 0);
|
||||||
Log3 $ioName, 2, "ERROR: cannot SEND_DATA to $hash->{NAME}: $arg";
|
Log3 $ioName, 2, "ERROR: cannot SEND_DATA to $hash->{NAME}: $arg";
|
||||||
ZWave_processSendStack($hash, "next");
|
ZWave_processSendStack($hash, "retry");
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
Log3 $ioName, 2, "ERROR: cannot SEND_DATA: $arg (unknown device)";
|
Log3 $ioName, 2, "ERROR: cannot SEND_DATA: $arg (unknown device)";
|
||||||
@ -3758,7 +3765,7 @@ ZWave_Parse($$@)
|
|||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
|
|
||||||
} else {
|
} else { # Wait for the retry timer to remove this cmd from the stack.
|
||||||
Log3 $ioName, 2, "$ioName transmit $lmsg for $callbackid";
|
Log3 $ioName, 2, "$ioName transmit $lmsg for $callbackid";
|
||||||
return "" if(!$hash);
|
return "" if(!$hash);
|
||||||
readingsSingleUpdate($hash, "state", "TRANSMIT_$lmsg", 1);
|
readingsSingleUpdate($hash, "state", "TRANSMIT_$lmsg", 1);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user