From f78ed4186c19872691163c76e9de986cd841e8b9 Mon Sep 17 00:00:00 2001 From: ntruchsess <> Date: Thu, 7 Aug 2014 22:01:18 +0000 Subject: [PATCH] OWX_ASYNC: move timeout to lowest level, configurable as attribute Merge branch 'owx_timeout' git-svn-id: https://svn.fhem.de/fhem/trunk@6378 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/00_OWX_ASYNC.pm | 16 +--------------- fhem/FHEM/21_OWAD.pm | 8 +------- fhem/FHEM/21_OWCOUNT.pm | 12 +----------- fhem/FHEM/21_OWLCD.pm | 40 +-------------------------------------- fhem/FHEM/21_OWMULTI.pm | 26 +------------------------ fhem/FHEM/21_OWSWITCH.pm | 20 +------------------- fhem/FHEM/21_OWTHERM.pm | 6 +----- fhem/FHEM/OWX_DS2480.pm | 2 ++ fhem/FHEM/OWX_DS9097.pm | 2 +- fhem/FHEM/OWX_FRM.pm | 6 +++++- fhem/FHEM/OWX_SER.pm | 2 +- 11 files changed, 16 insertions(+), 124 deletions(-) diff --git a/fhem/FHEM/00_OWX_ASYNC.pm b/fhem/FHEM/00_OWX_ASYNC.pm index d950990ae..6aa5ed260 100644 --- a/fhem/FHEM/00_OWX_ASYNC.pm +++ b/fhem/FHEM/00_OWX_ASYNC.pm @@ -133,7 +133,7 @@ my %attrs = ( ); #-- some globals needed for the 1-Wire module -$owx_async_version=5.13; +$owx_async_version=5.14; #-- Debugging 0,1,2,3 $owx_async_debug=0; @@ -367,9 +367,7 @@ sub OWX_ASYNC_PT_Alarms ($) { my ($thread) = @_; PT_BEGIN($thread); $thread->{pt_alarms} = $async->get_pt_alarms(); - $thread->{TimeoutTime} = gettimeofday()+2; #TODO: implement attribute-based timeout PT_WAIT_THREAD($thread->{pt_alarms}); - delete $thread->{TimeoutTime}; die $thread->{pt_alarms}->PT_CAUSE() if ($thread->{pt_alarms}->PT_STATE() == PT_ERROR); if (defined (my $alarmed_devs = $thread->{pt_alarms}->PT_RETVAL())) { OWX_ASYNC_AfterAlarms($hash,$alarmed_devs); @@ -444,9 +442,7 @@ sub OWX_ASYNC_PT_Discover ($) { my ($thread) = @_; PT_BEGIN($thread); $thread->{pt_discover} = $async->get_pt_discover(); - $thread->{TimeoutTime} = gettimeofday()+2; #TODO: implement attribute-based timeout PT_WAIT_THREAD($thread->{pt_discover}); - delete $thread->{TimeoutTime}; die $thread->{pt_discover}->PT_CAUSE() if ($thread->{pt_discover}->PT_STATE() == PT_ERROR); if (my $owx_devices = $thread->{pt_discover}->PT_RETVAL()) { PT_EXIT(OWX_ASYNC_AutoCreate($hash,$owx_devices)); @@ -485,9 +481,7 @@ sub OWX_ASYNC_PT_Search($) { my ($thread) = @_; PT_BEGIN($thread); $thread->{pt_discover} = $async->get_pt_discover(); - $thread->{TimeoutTime} = gettimeofday()+2; #TODO: implement attribute-based timeout PT_WAIT_THREAD($thread->{pt_discover}); - delete $thread->{TimeoutTime}; die $thread->{pt_discover}->PT_CAUSE() if ($thread->{pt_discover}->PT_STATE() == PT_ERROR); if (defined (my $owx_devs = $thread->{pt_discover}->PT_RETVAL())) { OWX_ASYNC_AfterSearch($hash,$owx_devs); @@ -829,9 +823,7 @@ sub OWX_ASYNC_Kick($) { Log3 $hash->{NAME},5,"OWX_ASYNC_PT_Kick: kicking DS14B20 temperature conversion"; #-- issue the skip ROM command \xCC followed by start conversion command \x44 $thread->{pt_execute} = OWX_ASYNC_PT_Execute($hash,1,undef,"\x44",0); - $thread->{TimeoutTime} = gettimeofday()+2; #TODO: implement attribute-based timeout PT_WAIT_THREAD($thread->{pt_execute}); - delete $thread->{TimeoutTime}; if ($thread->{pt_execute}->PT_STATE() == PT_ERROR) { Log3 ($hash->{NAME},4,"OWX_ASYNC_PT_Kick: Failure in temperature conversion: ".$thread->{pt_execute}->PT_CAUSE()); } else { @@ -849,16 +841,12 @@ sub OWX_ASYNC_Kick($) { } $thread->{pt_search} = OWX_ASYNC_PT_Search($hash); - $thread->{TimeoutTime} = gettimeofday()+2; #TODO: implement attribute-based timeout PT_WAIT_THREAD($thread->{pt_search}); - delete $thread->{Timeouttime}; if ($thread->{pt_search}->PT_STATE() == PT_ERROR) { Log3 ($hash->{NAME},4,"OWX_ASYNC_PT_Kick: Failure in search: ".$thread->{pt_search}->PT_CAUSE()); } else { $thread->{pt_alarms} = OWX_ASYNC_PT_Alarms($hash); - $thread->{TimeoutTime} = gettimeofday()+2; #TODO: implement attribute-based timeout PT_WAIT_THREAD($thread->{pt_alarms}); - delete $thread->{TimeoutTime}; if ($thread->{pt_alarms}->PT_STATE() == PT_ERROR) { Log3 ($hash->{NAME},4,"OWX_ASYNC_PT_Kick: Failure in alarm-search: ".$thread->{pt_alarms}->PT_CAUSE()); }; @@ -965,9 +953,7 @@ sub OWX_ASYNC_PT_Verify($) { if (defined $async) { $thread->{pt_verify} = $async->get_pt_verify($romid); - $thread->{TimeoutTime} = gettimeofday()+2; #TODO: implement attribute-based timeout PT_WAIT_THREAD($thread->{pt_verify}); - delete $thread->{TimeoutTime}; die $thread->{pt_verify}->PT_CAUSE() if ($thread->{pt_verify}->PT_STATE() == PT_ERROR); my $value = $thread->{pt_verify}->PT_RETVAL(); diff --git a/fhem/FHEM/21_OWAD.pm b/fhem/FHEM/21_OWAD.pm index 01908231a..2de3b26cf 100644 --- a/fhem/FHEM/21_OWAD.pm +++ b/fhem/FHEM/21_OWAD.pm @@ -90,7 +90,7 @@ use ProtoThreads; no warnings 'deprecated'; sub Log($$); -my $owx_version="5.18"; +my $owx_version="5.19"; #-- fixed raw channel name, flexible channel name my @owg_fixed = ("A","B","C","D"); my @owg_channel = ("A","B","C","D"); @@ -1572,9 +1572,7 @@ sub OWXAD_PT_GetPage($$$) { $thread->{pt_execute} = OWX_ASYNC_PT_Execute($master,1,$owx_dev, "\x3C\x0F\x00\xFF\xFF", 0 ); $thread->{ExecuteTime} = gettimeofday() + 0.07; # was 0.02 - $thread->{TimeoutTime} = gettimeofday()+2; #TODO: implement attribute-based timeout PT_WAIT_THREAD($thread->{pt_execute}); - delete $thread->{TimeoutTime}; die $thread->{pt_execute}->PT_CAUSE() if ($thread->{pt_execute}->PT_STATE() == PT_ERROR); PT_YIELD_UNTIL(gettimeofday() >= $thread->{ExecuteTime}); @@ -1600,9 +1598,7 @@ sub OWXAD_PT_GetPage($$$) { #-- reading 9 + 3 + 8 data bytes and 2 CRC bytes = 22 bytes $thread->{pt_execute} = OWX_ASYNC_PT_Execute($master,1,$owx_dev, $thread->{'select'}, 10 ); - $thread->{TimeoutTime} = gettimeofday()+2; #TODO: implement attribute-based timeout PT_WAIT_THREAD($thread->{pt_execute}); - delete $thread->{TimeoutTime}; die $thread->{pt_execute}->PT_CAUSE() if ($thread->{pt_execute}->PT_STATE() == PT_ERROR); my $response = $thread->{pt_execute}->PT_RETVAL(); my $res = OWXAD_BinValues($hash,"ds2450.get".$page.($final ? ".final" : ""),1,1,$owx_dev,$thread->{'select'},10,$response); @@ -1685,9 +1681,7 @@ sub OWXAD_PT_SetPage($$) { } #"setpage" $thread->{pt_execute} = OWX_ASYNC_PT_Execute($master,1,$owx_dev, $select, 0 ); - $thread->{TimeoutTime} = gettimeofday()+2; #TODO: implement attribute-based timeout PT_WAIT_THREAD($thread->{pt_execute}); - delete $thread->{TimeoutTime}; die $thread->{pt_execute}->PT_CAUSE() if ($thread->{pt_execute}->PT_STATE() == PT_ERROR); PT_END; }); diff --git a/fhem/FHEM/21_OWCOUNT.pm b/fhem/FHEM/21_OWCOUNT.pm index 92b532c97..d6526c323 100644 --- a/fhem/FHEM/21_OWCOUNT.pm +++ b/fhem/FHEM/21_OWCOUNT.pm @@ -99,7 +99,7 @@ no warnings 'deprecated'; sub Log3($$$); -my $owx_version="5.24"; +my $owx_version="5.25"; #-- fixed raw channel name, flexible channel name my @owg_fixed = ("A","B"); my @owg_channel = ("A","B"); @@ -1870,17 +1870,13 @@ sub OWXCOUNT_PT_GetPage($$$) { #-- reading 9 + 3 + 40 data bytes (32 byte memory, 4 byte counter + 4 byte zeroes) and 2 CRC bytes = 54 bytes $thread->{pt_execute} = OWX_ASYNC_PT_Execute($master,1,$owx_dev, $thread->{'select'}, 42 ); - $thread->{TimeoutTime} = gettimeofday()+2; #TODO: implement attribute-based timeout PT_WAIT_THREAD($thread->{pt_execute}); - delete $thread->{TimeoutTime}; die $thread->{pt_execute}->PT_CAUSE() if ($thread->{pt_execute}->PT_STATE() == PT_ERROR); $thread->{response} = $thread->{pt_execute}->PT_RETVAL(); #-- reset the bus (needed to stop receiving data ?) $thread->{pt_execute} = OWX_ASYNC_PT_Execute($master,1,undef,undef,undef); - $thread->{TimeoutTime} = gettimeofday()+2; #TODO: implement attribute-based timeout PT_WAIT_THREAD($thread->{pt_execute}); - delete $thread->{TimeoutTime}; die $thread->{pt_execute}->PT_CAUSE() if ($thread->{pt_execute}->PT_STATE() == PT_ERROR); if (my $ret = OWXCOUNT_BinValues($hash,"getpage.".$page.($final ? ".final" : ""),$owx_dev,$thread->{'select'},$thread->{response})) { @@ -1931,9 +1927,7 @@ sub OWXCOUNT_PT_SetPage($$$) { #"setpage.1" $thread->{pt_execute} = OWX_ASYNC_PT_Execute($master,1,$owx_dev, $thread->{'select'}, 0 ); - $thread->{TimeoutTime} = gettimeofday()+2; #TODO: implement attribute-based timeout PT_WAIT_THREAD($thread->{pt_execute}); - delete $thread->{TimeoutTime}; die $thread->{pt_execute}->PT_CAUSE() if ($thread->{pt_execute}->PT_STATE() == PT_ERROR); #-- issue the match ROM command \x55 and the read scratchpad command @@ -1943,9 +1937,7 @@ sub OWXCOUNT_PT_SetPage($$$) { # TODO: sometimes much less than 28 #"setpage.2" $thread->{pt_execute} = OWX_ASYNC_PT_Execute($master,1,$owx_dev, $thread->{'select'}, 28 ); - $thread->{TimeoutTime} = gettimeofday()+2; #TODO: implement attribute-based timeout PT_WAIT_THREAD($thread->{pt_execute}); - delete $thread->{TimeoutTime}; die $thread->{pt_execute}->PT_CAUSE() if ($thread->{pt_execute}->PT_STATE() == PT_ERROR); $res = $thread->{pt_execute}->PT_RETVAL(); if( length($res) < 13 ){ @@ -1959,9 +1951,7 @@ sub OWXCOUNT_PT_SetPage($$$) { #"setpage.3" $thread->{pt_execute} = OWX_ASYNC_PT_Execute($master,1,$owx_dev, $thread->{'select'}, 6 ); - $thread->{TimeoutTime} = gettimeofday()+2; #TODO: implement attribute-based timeout PT_WAIT_THREAD($thread->{pt_execute}); - delete $thread->{TimeoutTime}; die $thread->{pt_execute}->PT_CAUSE() if ($thread->{pt_execute}->PT_STATE() == PT_ERROR); $res = $thread->{pt_execute}->PT_RETVAL(); #TODO validate whether testing '0' is appropriate with async interface diff --git a/fhem/FHEM/21_OWLCD.pm b/fhem/FHEM/21_OWLCD.pm index d88d2fa8e..1392e6242 100644 --- a/fhem/FHEM/21_OWLCD.pm +++ b/fhem/FHEM/21_OWLCD.pm @@ -77,7 +77,7 @@ no warnings 'deprecated'; sub Log3($$$); -my $owx_version="5.2"; +my $owx_version="5.3"; #-- controller may be HD44780 or KS0073 # these values have to be changed for different display # geometries or memory maps @@ -845,9 +845,7 @@ sub OWXLCD_PT_Byte($$$) { #"byte" $thread->{pt_execute} = OWX_ASYNC_PT_Execute($master,1,$owx_dev,$select,0); - $thread->{TimeoutTime} = gettimeofday()+2; #TODO: implement attribute-based timeout PT_WAIT_THREAD($thread->{pt_execute}); - delete $thread->{TimeoutTime}; die $thread->{pt_execute}->PT_CAUSE() if ($thread->{pt_execute}->PT_STATE() == PT_ERROR); PT_END; }); @@ -963,16 +961,12 @@ sub OWXLCD_PT_Get($$) { } #"get.prepare" $thread->{pt_execute} = OWX_ASYNC_PT_Execute($master,1,$owx_dev,$select,0); - $thread->{TimeoutTime} = gettimeofday()+2; #TODO: implement attribute-based timeout PT_WAIT_THREAD($thread->{pt_execute}); - delete $thread->{TimeoutTime}; die $thread->{pt_execute}->PT_CAUSE() if ($thread->{pt_execute}->PT_STATE() == PT_ERROR); #-- issue the read scratchpad command \xBE $thread->{pt_execute} = OWX_ASYNC_PT_Execute($master,1,$owx_dev,"\xBE", $thread->{len}); - $thread->{TimeoutTime} = gettimeofday()+2; #TODO: implement attribute-based timeout PT_WAIT_THREAD($thread->{pt_execute}); - delete $thread->{TimeoutTime}; die $thread->{pt_execute}->PT_CAUSE() if ($thread->{pt_execute}->PT_STATE() == PT_ERROR); OWXLCD_BinValues($hash, "get.".$cmd, 1, 1, $owx_dev, "\xBE", $thread->{len}, $thread->{pt_execute}->PT_RETVAL()); @@ -1066,9 +1060,7 @@ sub OWXLCD_PT_GetMemory($$) { $select = sprintf("\4E%c\x10\x37",$page); #"prepare" $thread->{pt_execute} = OWX_ASYNC_PT_Execute($master,1,$owx_dev,$select,0); - $thread->{TimeoutTime} = gettimeofday()+2; #TODO: implement attribute-based timeout PT_WAIT_THREAD($thread->{pt_execute}); - delete $thread->{TimeoutTime}; die $thread->{pt_execute}->PT_CAUSE() if ($thread->{pt_execute}->PT_STATE() == PT_ERROR); #-- sleeping for some time @@ -1080,9 +1072,7 @@ sub OWXLCD_PT_GetMemory($$) { $thread->{'select'} = "\xBE"; #"get.memory.$page" $thread->{pt_execute} = OWX_ASYNC_PT_Execute($master,1,$owx_dev,$thread->{'select'},16); - $thread->{TimeoutTime} = gettimeofday()+2; #TODO: implement attribute-based timeout PT_WAIT_THREAD($thread->{pt_execute}); - delete $thread->{TimeoutTime}; die $thread->{pt_execute}->PT_CAUSE() if ($thread->{pt_execute}->PT_STATE() == PT_ERROR); OWXLCD_BinValues($hash, "get.memory.$page", 1, 1, $owx_dev, $thread->{'select'}, 16, $thread->{pt_execute}->PT_RETVAL()); @@ -1278,9 +1268,7 @@ sub OWXLCD_PT_SetFunction($$$) { } #"set.function" $thread->{pt_execute} = OWX_ASYNC_PT_Execute($master,1,$owx_dev,$select,0); - $thread->{TimeoutTime} = gettimeofday()+2; #TODO: implement attribute-based timeout PT_WAIT_THREAD($thread->{pt_execute}); - delete $thread->{TimeoutTime}; die $thread->{pt_execute}->PT_CAUSE() if ($thread->{pt_execute}->PT_STATE() == PT_ERROR); PT_END; @@ -1419,9 +1407,7 @@ sub OWXLCD_PT_SetIcon($$$) { $select = "\x10\x26"; #"set.icon.1" $thread->{pt_execute} = OWX_ASYNC_PT_Execute($master,1,$owx_dev,$select,0); - $thread->{TimeoutTime} = gettimeofday()+2; #TODO: implement attribute-based timeout PT_WAIT_THREAD($thread->{pt_execute}); - delete $thread->{TimeoutTime}; die $thread->{pt_execute}->PT_CAUSE() if ($thread->{pt_execute}->PT_STATE() == PT_ERROR); #-- SEGRAM addres to 0 = \x40, @@ -1430,18 +1416,14 @@ sub OWXLCD_PT_SetIcon($$$) { $select .= "\x4E\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"; #"set.icon.2" $thread->{pt_execute} = OWX_ASYNC_PT_Execute($master,1,$owx_dev,$select,0); - $thread->{TimeoutTime} = gettimeofday()+2; #TODO: implement attribute-based timeout PT_WAIT_THREAD($thread->{pt_execute}); - delete $thread->{TimeoutTime}; die $thread->{pt_execute}->PT_CAUSE() if ($thread->{pt_execute}->PT_STATE() == PT_ERROR); #-- issue the copy scratchpad to LCD command \x48 $select="\x48"; #"set.icon.3" $thread->{pt_execute} = OWX_ASYNC_PT_Execute($master,1,$owx_dev,$select,0); - $thread->{TimeoutTime} = gettimeofday()+2; #TODO: implement attribute-based timeout PT_WAIT_THREAD($thread->{pt_execute}); - delete $thread->{TimeoutTime}; die $thread->{pt_execute}->PT_CAUSE() if ($thread->{pt_execute}->PT_STATE() == PT_ERROR); } else { #-- determine data value @@ -1478,27 +1460,21 @@ sub OWXLCD_PT_SetIcon($$$) { $select = "\x10\x26"; #"set.icon.4" $thread->{pt_execute} = OWX_ASYNC_PT_Execute($master,1,$owx_dev,$select,0); - $thread->{TimeoutTime} = gettimeofday()+2; #TODO: implement attribute-based timeout PT_WAIT_THREAD($thread->{pt_execute}); - delete $thread->{TimeoutTime}; die $thread->{pt_execute}->PT_CAUSE() if ($thread->{pt_execute}->PT_STATE() == PT_ERROR); #-- SEGRAM addres to 0 = \x40 + icon address $select = sprintf("\x10%c",63+$icon); #"set.icon.5" $thread->{pt_execute} = OWX_ASYNC_PT_Execute($master,1,$owx_dev,$select,0); - $thread->{TimeoutTime} = gettimeofday()+2; #TODO: implement attribute-based timeout PT_WAIT_THREAD($thread->{pt_execute}); - delete $thread->{TimeoutTime}; die $thread->{pt_execute}->PT_CAUSE() if ($thread->{pt_execute}->PT_STATE() == PT_ERROR); #-- data $select = sprintf("\x12%c",$data); #"set.icon.6" $thread->{pt_execute} = OWX_ASYNC_PT_Execute($master,1,$owx_dev,$select,0); - $thread->{TimeoutTime} = gettimeofday()+2; #TODO: implement attribute-based timeout PT_WAIT_THREAD($thread->{pt_execute}); - delete $thread->{TimeoutTime}; die $thread->{pt_execute}->PT_CAUSE() if ($thread->{pt_execute}->PT_STATE() == PT_ERROR); } @@ -1506,9 +1482,7 @@ sub OWXLCD_PT_SetIcon($$$) { $select = "\x10\x20"; #"set.icon.7" $thread->{pt_execute} = OWX_ASYNC_PT_Execute($master,1,$owx_dev,$select,0); - $thread->{TimeoutTime} = gettimeofday()+2; #TODO: implement attribute-based timeout PT_WAIT_THREAD($thread->{pt_execute}); - delete $thread->{TimeoutTime}; die $thread->{pt_execute}->PT_CAUSE() if ($thread->{pt_execute}->PT_STATE() == PT_ERROR); #-- or else } else { @@ -1666,18 +1640,14 @@ sub OWXLCD_PT_SetLine($$$) { $select=sprintf("\x4E%c",$lcdpage[$line]).$msgA; #"set.line.1" $thread->{pt_execute} = OWX_ASYNC_PT_Execute($master,1,$owx_dev,$select,0); - $thread->{TimeoutTime} = gettimeofday()+2; #TODO: implement attribute-based timeout PT_WAIT_THREAD($thread->{pt_execute}); - delete $thread->{TimeoutTime}; die $thread->{pt_execute}->PT_CAUSE() if ($thread->{pt_execute}->PT_STATE() == PT_ERROR); #-- issue the copy scratchpad to LCD command \x48 $select="\x48"; #"set.line.2" $thread->{pt_execute} = OWX_ASYNC_PT_Execute($master,1,$owx_dev,$select,0); - $thread->{TimeoutTime} = gettimeofday()+2; #TODO: implement attribute-based timeout PT_WAIT_THREAD($thread->{pt_execute}); - delete $thread->{TimeoutTime}; die $thread->{pt_execute}->PT_CAUSE() if ($thread->{pt_execute}->PT_STATE() == PT_ERROR); #-- if second string available: @@ -1688,18 +1658,14 @@ sub OWXLCD_PT_SetLine($$$) { $select=sprintf("\x4E%c",$lcdpage[$line]+16).$thread->{msgB}; #"set.line.3" $thread->{pt_execute} = OWX_ASYNC_PT_Execute($master,1,$owx_dev,$select,0); - $thread->{TimeoutTime} = gettimeofday()+2; #TODO: implement attribute-based timeout PT_WAIT_THREAD($thread->{pt_execute}); - delete $thread->{TimeoutTime}; die $thread->{pt_execute}->PT_CAUSE() if ($thread->{pt_execute}->PT_STATE() == PT_ERROR); #-- issue the copy scratchpad to LCD command \x48 $select="\x48"; #"set.line.4" $thread->{pt_execute} = OWX_ASYNC_PT_Execute($master,1,$owx_dev,$select,0); - $thread->{TimeoutTime} = gettimeofday()+2; #TODO: implement attribute-based timeout PT_WAIT_THREAD($thread->{pt_execute}); - delete $thread->{TimeoutTime}; die $thread->{pt_execute}->PT_CAUSE() if ($thread->{pt_execute}->PT_STATE() == PT_ERROR); } PT_END; @@ -1825,18 +1791,14 @@ sub OWXLCD_PT_SetMemory($$$) { $select=sprintf("\x4E\%c",$page).$msgA; #"set.memory.page" $thread->{pt_execute} = OWX_ASYNC_PT_Execute($master,1,$owx_dev,$select,0); - $thread->{TimeoutTime} = gettimeofday()+2; #TODO: implement attribute-based timeout PT_WAIT_THREAD($thread->{pt_execute}); - delete $thread->{TimeoutTime}; die $thread->{pt_execute}->PT_CAUSE() if ($thread->{pt_execute}->PT_STATE() == PT_ERROR); #-- issue the copy scratchpad to EEPROM command \x39 $select = "\x39"; #"set.memory.copy" $thread->{pt_execute} = OWX_ASYNC_PT_Execute($master,1,$owx_dev,$select,0); - $thread->{TimeoutTime} = gettimeofday()+2; #TODO: implement attribute-based timeout PT_WAIT_THREAD($thread->{pt_execute}); - delete $thread->{TimeoutTime}; die $thread->{pt_execute}->PT_CAUSE() if ($thread->{pt_execute}->PT_STATE() == PT_ERROR); PT_END; }); diff --git a/fhem/FHEM/21_OWMULTI.pm b/fhem/FHEM/21_OWMULTI.pm index 5cdcaeb4f..5dc7b54aa 100644 --- a/fhem/FHEM/21_OWMULTI.pm +++ b/fhem/FHEM/21_OWMULTI.pm @@ -82,7 +82,7 @@ no warnings 'deprecated'; sub Log($$); -my $owx_version="5.18"; +my $owx_version="5.19"; #-- flexible channel name my $owg_channel; @@ -1059,18 +1059,14 @@ sub OWXMULTI_PT_GetValues($) { #-- issue the match ROM command \x55 and the write scratchpad command #"ds2438.writestatusvdd" $thread->{pt_execute} = OWX_ASYNC_PT_Execute($master,1,$owx_dev,"\x4E\x00\x08",0); - $thread->{TimeoutTime} = gettimeofday()+2; #TODO: implement attribute-based timeout PT_WAIT_THREAD($thread->{pt_execute}); - delete $thread->{TimeoutTime}; die $thread->{pt_execute}->PT_CAUSE() if ($thread->{pt_execute}->PT_STATE() == PT_ERROR); #-- copy scratchpad to register #-- issue the match ROM command \x55 and the copy scratchpad command #"ds2438.copyscratchpadvdd" $thread->{pt_execute} = OWX_ASYNC_PT_Execute($master,1,$owx_dev,"\x48\x00",0); - $thread->{TimeoutTime} = gettimeofday()+2; #TODO: implement attribute-based timeout PT_WAIT_THREAD($thread->{pt_execute}); - delete $thread->{TimeoutTime}; die $thread->{pt_execute}->PT_CAUSE() if ($thread->{pt_execute}->PT_STATE() == PT_ERROR); #-- initiate temperature conversion @@ -1078,10 +1074,8 @@ sub OWXMULTI_PT_GetValues($) { #-- issue the match ROM command \x55 and the start conversion command #"ds2438.temperaturconversionvdd" $thread->{pt_execute} = OWX_ASYNC_PT_Execute($master,1,$owx_dev,"\x44",0); - $thread->{TimeoutTime} = gettimeofday()+2; #TODO: implement attribute-based timeout $thread->{ExecuteTime} = gettimeofday() + 0.03; # was 0.012 PT_WAIT_THREAD($thread->{pt_execute}); - delete $thread->{TimeoutTime}; die $thread->{pt_execute}->PT_CAUSE() if ($thread->{pt_execute}->PT_STATE() == PT_ERROR); PT_YIELD_UNTIL(gettimeofday() >= $thread->{ExecuteTime}); delete $thread->{ExecuteTime}; @@ -1091,10 +1085,8 @@ sub OWXMULTI_PT_GetValues($) { #-- issue the match ROM command \x55 and the start conversion command #"ds2438.voltageconversionvdd" $thread->{pt_execute} = OWX_ASYNC_PT_Execute($master,1,$owx_dev,"\xB4",0); - $thread->{TimeoutTime} = gettimeofday()+2; #TODO: implement attribute-based timeout $thread->{ExecuteTime} = gettimeofday() + 0.02; # was 0.006 PT_WAIT_THREAD($thread->{pt_execute}); - delete $thread->{TimeoutTime}; die $thread->{pt_execute}->PT_CAUSE() if ($thread->{pt_execute}->PT_STATE() == PT_ERROR); PT_YIELD_UNTIL(gettimeofday() >= $thread->{ExecuteTime}); delete $thread->{ExecuteTime}; @@ -1104,10 +1096,8 @@ sub OWXMULTI_PT_GetValues($) { #-- issue the match ROM command \x55 and the recall memory command #"ds2438.recallmemoryvdd" $thread->{pt_execute} = OWX_ASYNC_PT_Execute($master,1,$owx_dev,"\xB8\x00",0); - $thread->{TimeoutTime} = gettimeofday()+2; #TODO: implement attribute-based timeout $thread->{ExecuteTime} = gettimeofday() + 0.03; # was 0.012 PT_WAIT_THREAD($thread->{pt_execute}); - delete $thread->{TimeoutTime}; die $thread->{pt_execute}->PT_CAUSE() if ($thread->{pt_execute}->PT_STATE() == PT_ERROR); PT_YIELD_UNTIL(gettimeofday() >= $thread->{ExecuteTime}); delete $thread->{ExecuteTime}; @@ -1117,9 +1107,7 @@ sub OWXMULTI_PT_GetValues($) { #-- reading 9 + 2 + 9 data bytes = 20 bytes #"ds2438.getvdd" $thread->{pt_execute} = OWX_ASYNC_PT_Execute($master,1,$owx_dev,"\xBE\x00",9); - $thread->{TimeoutTime} = gettimeofday()+2; #TODO: implement attribute-based timeout PT_WAIT_THREAD($thread->{pt_execute}); - delete $thread->{TimeoutTime}; die $thread->{pt_execute}->PT_CAUSE() if ($thread->{pt_execute}->PT_STATE() == PT_ERROR); $res = $thread->{pt_execute}->PT_RETVAL(); unless (defined $res and length($res)==9) { @@ -1134,18 +1122,14 @@ sub OWXMULTI_PT_GetValues($) { #-- issue the match ROM command \x55 and the write scratchpad command #"ds2438.writestatusvad" $thread->{pt_execute} = OWX_ASYNC_PT_Execute($master,1,$owx_dev,"\x4E\x00\x00",0); - $thread->{TimeoutTime} = gettimeofday()+2; #TODO: implement attribute-based timeout PT_WAIT_THREAD($thread->{pt_execute}); - delete $thread->{TimeoutTime}; die $thread->{pt_execute}->PT_CAUSE() if ($thread->{pt_execute}->PT_STATE() == PT_ERROR); #-- copy scratchpad to register #-- issue the match ROM command \x55 and the copy scratchpad command #"ds2438.copyscratchpadvad" $thread->{pt_execute} = OWX_ASYNC_PT_Execute($master,1,$owx_dev,"\x48\x00",0); - $thread->{TimeoutTime} = gettimeofday()+2; #TODO: implement attribute-based timeout PT_WAIT_THREAD($thread->{pt_execute}); - delete $thread->{TimeoutTime}; die $thread->{pt_execute}->PT_CAUSE() if ($thread->{pt_execute}->PT_STATE() == PT_ERROR); #-- initiate voltage conversion @@ -1153,10 +1137,8 @@ sub OWXMULTI_PT_GetValues($) { #-- issue the match ROM command \x55 and the start conversion command #"ds2438.voltageconversionvad" $thread->{pt_execute} = OWX_ASYNC_PT_Execute($master,1,$owx_dev,"\xB4",0); - $thread->{TimeoutTime} = gettimeofday()+2; #TODO: implement attribute-based timeout $thread->{ExecuteTime} = gettimeofday() + 0.02; # was 0.006 PT_WAIT_THREAD($thread->{pt_execute}); - delete $thread->{TimeoutTime}; die $thread->{pt_execute}->PT_CAUSE() if ($thread->{pt_execute}->PT_STATE() == PT_ERROR); PT_YIELD_UNTIL(gettimeofday() >= $thread->{ExecuteTime}); delete $thread->{ExecuteTime}; @@ -1166,10 +1148,8 @@ sub OWXMULTI_PT_GetValues($) { #-- issue the match ROM command \x55 and the recall memory command #"ds2438.recallmemoryvad" $thread->{pt_execute} = OWX_ASYNC_PT_Execute($master,1,$owx_dev,"\xB8\x00",0); - $thread->{TimeoutTime} = gettimeofday()+2; #TODO: implement attribute-based timeout $thread->{ExecuteTime} = gettimeofday() + 0.03; # was 0.012 PT_WAIT_THREAD($thread->{pt_execute}); - delete $thread->{TimeoutTime}; die $thread->{pt_execute}->PT_CAUSE() if ($thread->{pt_execute}->PT_STATE() == PT_ERROR); PT_YIELD_UNTIL(gettimeofday() >= $thread->{ExecuteTime}); delete $thread->{ExecuteTime}; @@ -1179,9 +1159,7 @@ sub OWXMULTI_PT_GetValues($) { #-- reading 9 + 2 + 9 data bytes = 20 bytes #"ds2438.getvad" $thread->{pt_execute} = OWX_ASYNC_PT_Execute($master,1,$owx_dev,"\xBE\x00", 9); - $thread->{TimeoutTime} = gettimeofday()+2; #TODO: implement attribute-based timeout PT_WAIT_THREAD($thread->{pt_execute}); - delete $thread->{TimeoutTime}; die $thread->{pt_execute}->PT_CAUSE() if ($thread->{pt_execute}->PT_STATE() == PT_ERROR); #-- process results @@ -1237,9 +1215,7 @@ sub OWXMULTI_PT_SetValues($@) { my $select=sprintf("\x4E%c%c\x48",0,0); #"setvalues" $thread->{pt_execute} = OWX_ASYNC_PT_Execute($master,1,$owx_dev,$select, 0); - $thread->{TimeoutTime} = gettimeofday()+2; #TODO: implement attribute-based timeout PT_WAIT_THREAD($thread->{pt_execute}); - delete $thread->{TimeoutTime}; die $thread->{pt_execute}->PT_CAUSE() if ($thread->{pt_execute}->PT_STATE() == PT_ERROR); PT_END; diff --git a/fhem/FHEM/21_OWSWITCH.pm b/fhem/FHEM/21_OWSWITCH.pm index 849de1aee..3dbc4659f 100644 --- a/fhem/FHEM/21_OWSWITCH.pm +++ b/fhem/FHEM/21_OWSWITCH.pm @@ -89,7 +89,7 @@ no warnings 'deprecated'; sub Log($$); -my $owx_version="5.18"; +my $owx_version="5.19"; #-- fixed raw channel name, flexible channel name my @owg_fixed = ("A","B","C","D","E","F","G","H"); my @owg_channel = ("A","B","C","D","E","F","G","H"); @@ -1297,9 +1297,7 @@ sub OWXSWITCH_PT_GetState($) { #-- reading 9 + 3 + 2 data bytes + 2 CRC bytes = 16 bytes $thread->{'select'}=sprintf("\xF5\xDD\xFF"); $thread->{pt_execute} = OWX_ASYNC_PT_Execute($master,1,$owx_dev,$thread->{'select'},4); - $thread->{TimeoutTime} = gettimeofday()+2; #TODO: implement attribute-based timeout PT_WAIT_THREAD($thread->{pt_execute}); - delete $thread->{TimeoutTime}; die $thread->{pt_execute}->PT_CAUSE() if ($thread->{pt_execute}->PT_STATE() == PT_ERROR); $response = $thread->{pt_execute}->PT_RETVAL(); unless (length($response) == 4) { @@ -1317,9 +1315,7 @@ sub OWXSWITCH_PT_GetState($) { #-- reading 9 + 3 + 8 data bytes + 2 CRC bytes = 22 bytes $thread->{'select'}=sprintf("\xF0\x88\x00"); $thread->{pt_execute} = OWX_ASYNC_PT_Execute($master,1,$owx_dev,$thread->{'select'},10); - $thread->{TimeoutTime} = gettimeofday()+2; #TODO: implement attribute-based timeout PT_WAIT_THREAD($thread->{pt_execute}); - delete $thread->{TimeoutTime}; die $thread->{pt_execute}->PT_CAUSE() if ($thread->{pt_execute}->PT_STATE() == PT_ERROR); $response = $thread->{pt_execute}->PT_RETVAL(); unless (length($response) == 10) { @@ -1337,9 +1333,7 @@ sub OWXSWITCH_PT_GetState($) { #-- reading 9 + 1 + 2 data bytes = 12 bytes $thread->{'select'}="\xF5"; $thread->{pt_execute} = OWX_ASYNC_PT_Execute($master,1,$owx_dev,$thread->{'select'},2); - $thread->{TimeoutTime} = gettimeofday()+2; #TODO: implement attribute-based timeout PT_WAIT_THREAD($thread->{pt_execute}); - delete $thread->{TimeoutTime}; die $thread->{pt_execute}->PT_CAUSE() if ($thread->{pt_execute}->PT_STATE() == PT_ERROR); $response = $thread->{pt_execute}->PT_RETVAL(); unless (length($response) == 2) { @@ -1392,9 +1386,7 @@ sub OWXSWITCH_PT_SetState($$) { #-- reading 9 + 3 + 1 data bytes + 2 CRC bytes = 15 bytes $thread->{pt_execute} = OWX_ASYNC_PT_Execute($master,1,$owx_dev,"\xAA\x07\x00", 3); - $thread->{TimeoutTime} = gettimeofday()+2; #TODO: implement attribute-based timeout PT_WAIT_THREAD($thread->{pt_execute}); - delete $thread->{TimeoutTime}; die $thread->{pt_execute}->PT_CAUSE() if ($thread->{pt_execute}->PT_STATE() == PT_ERROR); $res = $thread->{pt_execute}->PT_RETVAL(); @@ -1408,9 +1400,7 @@ sub OWXSWITCH_PT_SetState($$) { $thread->{'select'}=sprintf("\x55\x07\x00%c",$statneu); $thread->{pt_execute} = OWX_ASYNC_PT_Execute($master,1,$owx_dev,$thread->{'select'}, 2); - $thread->{TimeoutTime} = gettimeofday()+2; #TODO: implement attribute-based timeout PT_WAIT_THREAD($thread->{pt_execute}); - delete $thread->{TimeoutTime}; die $thread->{pt_execute}->PT_CAUSE() if ($thread->{pt_execute}->PT_STATE() == PT_ERROR); $res = $thread->{pt_execute}->PT_RETVAL(); @@ -1439,9 +1429,7 @@ sub OWXSWITCH_PT_SetState($$) { $select=sprintf("\x5A%c%c",$value,255-$value); $thread->{pt_execute} = OWX_ASYNC_PT_Execute($master,1,$owx_dev,$select, 1); - $thread->{TimeoutTime} = gettimeofday()+2; #TODO: implement attribute-based timeout PT_WAIT_THREAD($thread->{pt_execute}); - delete $thread->{TimeoutTime}; die $thread->{pt_execute}->PT_CAUSE() if ($thread->{pt_execute}->PT_STATE() == PT_ERROR); $res = $thread->{pt_execute}->PT_RETVAL(); @@ -1460,9 +1448,7 @@ sub OWXSWITCH_PT_SetState($$) { # \x5A plus the value byte and its complement $select=sprintf("\x5A%c%c",252+$value,3-$value); $thread->{pt_execute} = OWX_ASYNC_PT_Execute($master,1,$owx_dev,$select, 1); - $thread->{TimeoutTime} = gettimeofday()+2; #TODO: implement attribute-based timeout PT_WAIT_THREAD($thread->{pt_execute}); - delete $thread->{TimeoutTime}; die $thread->{pt_execute}->PT_CAUSE() if ($thread->{pt_execute}->PT_STATE() == PT_ERROR); $res = $thread->{pt_execute}->PT_RETVAL(); @@ -1492,9 +1478,7 @@ sub OWXSWITCH_PT_SetOutput($$$) { PT_BEGIN($thread); $thread->{task} = OWXSWITCH_PT_GetState($hash); - $thread->{TimeoutTime} = gettimeofday()+2; #TODO: implement attribute-based timeout PT_WAIT_THREAD($thread->{task}); - delete $thread->{TimeoutTime}; die $thread->{task}->PT_CAUSE() if ($thread->{task}->PT_STATE() == PT_ERROR); $ret = $thread->{task}->PT_RETVAL(); die $ret if $ret; @@ -1508,9 +1492,7 @@ sub OWXSWITCH_PT_SetOutput($$$) { } $thread->{value} = $value; $thread->{task} = OWXSWITCH_PT_SetState($hash,$thread->{value}); - $thread->{TimeoutTime} = gettimeofday()+2; #TODO: implement attribute-based timeout PT_WAIT_THREAD($thread->{task}); - delete $thread->{TimeoutTime}; die $thread->{task}->PT_CAUSE() if ($thread->{task}->PT_STATE() == PT_ERROR); $ret = $thread->{task}->PT_RETVAL(); die $ret if $ret; diff --git a/fhem/FHEM/21_OWTHERM.pm b/fhem/FHEM/21_OWTHERM.pm index e1c2af157..7ace17bcc 100644 --- a/fhem/FHEM/21_OWTHERM.pm +++ b/fhem/FHEM/21_OWTHERM.pm @@ -86,7 +86,7 @@ no warnings 'deprecated'; sub Log3($$$); sub AttrVal($$$); -my $owx_version="5.24"; +my $owx_version="5.25"; my %gets = ( "id" => "", @@ -1128,9 +1128,7 @@ sub OWXTHERM_PT_GetValues($) { my $delay = $convtimes{AttrVal($name,"resolution",12)}; $thread->{ExecuteTime} = $now + $delay*0.001; $thread->{pt_execute} = OWX_ASYNC_PT_Execute($master,1,$owx_dev,"\x44",0); - $thread->{TimeoutTime} = gettimeofday()+2; #TODO: implement attribute-based timeout PT_WAIT_THREAD($thread->{pt_execute}); - delete $thread->{TimeoutTime}; die $thread->{pt_execute}->PT_CAUSE() if ($thread->{pt_execute}->PT_STATE() == PT_ERROR); PT_YIELD_UNTIL(gettimeofday() >= $thread->{ExecuteTime}); delete $thread->{ExecuteTime}; @@ -1139,9 +1137,7 @@ sub OWXTHERM_PT_GetValues($) { #-- issue the match ROM command \x55 and the read scratchpad command \xBE #-- reading 9 + 1 + 8 data bytes and 1 CRC byte = 19 bytes $thread->{pt_execute} = OWX_ASYNC_PT_Execute($master,1,$owx_dev,"\xBE",9); - $thread->{TimeoutTime} = gettimeofday()+2; #TODO: implement attribute-based timeout PT_WAIT_THREAD($thread->{pt_execute}); - delete $thread->{TimeoutTime}; die $thread->{pt_execute}->PT_CAUSE() if ($thread->{pt_execute}->PT_STATE() == PT_ERROR); OWXTHERM_BinValues($hash,1,$owx_dev,undef,9,$thread->{pt_execute}->PT_RETVAL()); PT_END; diff --git a/fhem/FHEM/OWX_DS2480.pm b/fhem/FHEM/OWX_DS2480.pm index 255347998..2428ff3eb 100644 --- a/fhem/FHEM/OWX_DS2480.pm +++ b/fhem/FHEM/OWX_DS2480.pm @@ -104,6 +104,7 @@ sub get_pt_execute($$$$) { $self->block($select); } + main::OWX_ASYNC_TaskTimeout($self->{hash},gettimeofday+main::AttrVal($self->{name},"timeout",2)); PT_WAIT_UNTIL($self->response_ready()); if ($reset and !$self->reset_response()) { @@ -348,6 +349,7 @@ sub pt_next ($$) { $serial->reset(); $serial->query($sp1,1); $serial->query($sp2,16); + main::OWX_ASYNC_TaskTimeout($serial->{hash},gettimeofday+main::AttrVal($serial->{name},"timeout",2)); PT_WAIT_UNTIL($serial->response_ready()); die "reset failed" unless $serial->reset_response(); diff --git a/fhem/FHEM/OWX_DS9097.pm b/fhem/FHEM/OWX_DS9097.pm index ddd3f344e..1a3535cb0 100644 --- a/fhem/FHEM/OWX_DS9097.pm +++ b/fhem/FHEM/OWX_DS9097.pm @@ -157,7 +157,7 @@ sub pt_query($) { while (defined ($bit = shift @bitsout)) { $serial->bit($bit); }; - main::OWX_ASYNC_TaskTimeout($serial->{hash},gettimeofday+1); + main::OWX_ASYNC_TaskTimeout($serial->{hash},gettimeofday+main::AttrVal($serial->{name},"timeout",1)); PT_WAIT_UNTIL(length($serial->{string_raw}) >= $numbits); $bitsin = join "", map { ($_ == 0xFF) ? "1" : "0" } unpack "C*",$serial->{string_raw}; main::Log3($serial->{name},5,"OWX_DS9097 pt_query in: ".$bitsin) if ( $main::owx_async_debug ); diff --git a/fhem/FHEM/OWX_FRM.pm b/fhem/FHEM/OWX_FRM.pm index fff07883b..bb837fcd5 100644 --- a/fhem/FHEM/OWX_FRM.pm +++ b/fhem/FHEM/OWX_FRM.pm @@ -47,7 +47,7 @@ sub new() { interface => "firmata", #-- module version - version => 4.1 + version => 4.2 }, $class; } @@ -178,6 +178,7 @@ sub get_pt_discover() { PT_BEGIN($thread); delete $self->{devs}; main::FRM_Client_FirmataDevice($self->{hash})->onewire_search($self->{pin}); + main::OWX_ASYNC_TaskTimeout($self->{hash},gettimeofday+main::AttrVal($self->{name},"timeout",2)); PT_WAIT_UNTIL(defined $self->{devs}); PT_EXIT($self->{devs}); PT_END; @@ -199,6 +200,7 @@ sub get_pt_alarms() { PT_BEGIN($thread); delete $self->{alarmdevs}; main::FRM_Client_FirmataDevice($self->{hash})->onewire_search_alarms($self->{pin}); + main::OWX_ASYNC_TaskTimeout($self->{hash},gettimeofday+main::AttrVal($self->{name},"timeout",2)); PT_WAIT_UNTIL(defined $self->{alarmdevs}); PT_EXIT($self->{alarmdevs}); PT_END; @@ -212,6 +214,7 @@ sub get_pt_verify($) { PT_BEGIN($thread); delete $self->{devs}; main::FRM_Client_FirmataDevice($self->{hash})->onewire_search($self->{pin}); + main::OWX_ASYNC_TaskTimeout($self->{hash},gettimeofday+main::AttrVal($self->{name},"timeout",2)); PT_WAIT_UNTIL(defined $self->{devs}); PT_EXIT(scalar(grep {$dev eq $_} @{$self->{devs}})); PT_END; @@ -257,6 +260,7 @@ sub get_pt_execute($$$$) { $thread->{id} = $id; $self->{id} = ( $id + 1 ) & 0xFFFF; delete $self->{responses}->{$id}; + main::OWX_ASYNC_TaskTimeout($self->{hash},gettimeofday+main::AttrVal($self->{name},"timeout",2)); PT_WAIT_UNTIL(defined $self->{responses}->{$thread->{id}}); my $ret = pack "C*", @{$self->{responses}->{$thread->{id}}}; delete $self->{responses}->{$thread->{id}}; diff --git a/fhem/FHEM/OWX_SER.pm b/fhem/FHEM/OWX_SER.pm index 28442fdb6..8b9d654a9 100644 --- a/fhem/FHEM/OWX_SER.pm +++ b/fhem/FHEM/OWX_SER.pm @@ -47,7 +47,7 @@ sub new() { my $self = { interface => "serial", #-- module version - version => 5.1, + version => 5.2, alarmdevs => [], devs => [], fams => [],