10_pilight_ctrl: fix: reset - clear send queue, new: add attribute SendTimeout

git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@8811 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
risiko79 2015-06-23 20:14:02 +00:00
parent d22ddc6e54
commit 85d34bd52b
2 changed files with 14 additions and 4 deletions

View File

@ -1,5 +1,7 @@
# Add changes at the top of the list. Keep it in ASCII, and 80-char wide. # Add changes at the top of the list. Keep it in ASCII, and 80-char wide.
# Do not insert empty lines here, update check depends on it. # Do not insert empty lines here, update check depends on it.
- bugfix: pilight_ctrl: reset - clear send queue
- feature: pilight_ctrl: add attribute SendTimeout for aborting sending commands
- feature: FB_CALLMONITOR: add TR-064 support for remote phonebook reading - feature: FB_CALLMONITOR: add TR-064 support for remote phonebook reading
via official AVM API (by JoWiemann) via official AVM API (by JoWiemann)
- feature: 10_pilight_ctrl.pm: added disconnect - feature: 10_pilight_ctrl.pm: added disconnect

View File

@ -1,5 +1,5 @@
############################################## ##############################################
# $Id: 10_pilight_ctrl.pm 1.07 2015-06-23 Risiko $ # $Id: 10_pilight_ctrl.pm 1.08 2015-06-23 Risiko $
# #
# Usage # Usage
# #
@ -31,6 +31,8 @@
# V 1.05 2015-06-07 - FIX: Reset # V 1.05 2015-06-07 - FIX: Reset
# V 1.06 2015-06-20 - NEW: set <ctrl> disconnect, checking reading state # V 1.06 2015-06-20 - NEW: set <ctrl> disconnect, checking reading state
# V 1.07 2015-06-23 - FIX: reading state always contains a valid value, checking reading state removed # V 1.07 2015-06-23 - FIX: reading state always contains a valid value, checking reading state removed
# V 1.08 2015-06-23 - FIX: clear send queue by reset
# V 1.08 2015-06-23 - NEW: attribute SendTimeout for abort sending command non blocking
############################################## ##############################################
package main; package main;
@ -76,7 +78,7 @@ sub pilight_ctrl_Initialize($)
$hash->{SetFn} = "pilight_ctrl_Set"; $hash->{SetFn} = "pilight_ctrl_Set";
$hash->{NotifyFn}= "pilight_ctrl_Notify"; $hash->{NotifyFn}= "pilight_ctrl_Notify";
$hash->{StateFn} = "pilight_ctrl_State"; $hash->{StateFn} = "pilight_ctrl_State";
$hash->{AttrList}= "ignoreProtocol brands ContactAsSwitch ".$readingFnAttributes; $hash->{AttrList}= "ignoreProtocol brands ContactAsSwitch SendTimeout ".$readingFnAttributes;
$hash->{Clients} = ":pilight_switch:pilight_dimmer:pilight_temp:"; $hash->{Clients} = ":pilight_switch:pilight_dimmer:pilight_temp:";
#$hash->{MatchList} = \%matchList; #only for autocreate #$hash->{MatchList} = \%matchList; #only for autocreate
@ -177,6 +179,8 @@ sub pilight_ctrl_Close($)
delete($hash->{helper}{RUNNING_PID}); delete($hash->{helper}{RUNNING_PID});
} }
splice($hash->{helper}->{sendQueue});
RemoveInternalTimer($hash); RemoveInternalTimer($hash);
Log3 $me, 5, "$me(Close): close DevIo"; Log3 $me, 5, "$me(Close): close DevIo";
DevIo_CloseDev($hash); DevIo_CloseDev($hash);
@ -616,7 +620,7 @@ sub pilight_ctrl_SendNonBlocking($)
my $blockingFn = "pilight_ctrl_Send"; my $blockingFn = "pilight_ctrl_Send";
my $arg = $me."|".$hash->{DeviceName}."|".$data; my $arg = $me."|".$hash->{DeviceName}."|".$data;
my $finishFn = "pilight_ctrl_SendDone"; my $finishFn = "pilight_ctrl_SendDone";
my $timeout = 4; my $timeout = AttrVal($me, "SendTimeout",1);
my $abortFn = "pilight_ctrl_SendAbort"; my $abortFn = "pilight_ctrl_SendAbort";
$hash->{helper}{RUNNING_PID} = BlockingCall($blockingFn, $arg, $finishFn, $timeout, $abortFn, $hash); $hash->{helper}{RUNNING_PID} = BlockingCall($blockingFn, $arg, $finishFn, $timeout, $abortFn, $hash);
@ -625,6 +629,7 @@ sub pilight_ctrl_SendNonBlocking($)
Log3 $me, 5, "$me(Write): Blocking Call running - will try it later"; Log3 $me, 5, "$me(Write): Blocking Call running - will try it later";
} }
$queueSize = @{$hash->{helper}->{sendQueue}};
InternalTimer(gettimeofday()+0.5,"pilight_ctrl_SendNonBlocking", $hash, 0) if ($queueSize > 0); InternalTimer(gettimeofday()+0.5,"pilight_ctrl_SendNonBlocking", $hash, 0) if ($queueSize > 0);
} }
@ -947,6 +952,9 @@ sub pilight_ctrl_SimpleWrite(@)
In this case opened will be interpreted as on and closed as off.<br> In this case opened will be interpreted as on and closed as off.<br>
Example: <code>ContactAsSwitch 12345</code> Example: <code>ContactAsSwitch 12345</code>
</li> </li>
<li><a name="SendTimeout">SendTimeout</a><br>
Timeout [s] for aborting sending commands (non blocking) - default 1s
</li>
</ul> </ul>
<br> <br>