36_LaCrosseGateway.pm: fixed crazy logging when no connect is possible

git-svn-id: https://svn.fhem.de/fhem/trunk@12214 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
hcs-svn 2016-09-26 20:13:32 +00:00
parent 0e2fbaf10a
commit 97dc2bcec2

View File

@ -216,11 +216,11 @@ sub LaCrosseGateway_DoInit($) {
} }
#======================================================================================= #=======================================================================================
sub LaCrosseGateway_Ready($) { sub LaCrosseGateway_Ready($) {
my ($hash) = @_; my ($hash) = @_;
my $name = $hash->{NAME};
return LaCrosseGateway_Connect($hash) if($hash->{STATE} eq "disconnected"); LaCrosseGateway_Connect($hash, 1);
# This is relevant for windows/USB only # This is relevant for windows/USB only
my $po = $hash->{USBDev}; my $po = $hash->{USBDev};
@ -414,13 +414,14 @@ sub LaCrosseGateway_SimpleWrite(@) {
} }
#======================================================================================= #=======================================================================================
sub LaCrosseGateway_Connect($) { sub LaCrosseGateway_Connect($;$) {
my ($hash) = @_; my ($hash, $mode) = @_;
my $name = $hash->{NAME}; my $name = $hash->{NAME};
$mode = 0 if!($mode);
my $enabled = AttrVal($name, "disable", "0") != "1"; my $enabled = AttrVal($name, "disable", "0") != "1";
if($enabled) { if($enabled) {
my $ret = DevIo_OpenDev($hash, 0, "LaCrosseGateway_DoInit"); my $ret = DevIo_OpenDev($hash, $mode, "LaCrosseGateway_DoInit");
return $ret; return $ret;
} }
@ -432,10 +433,11 @@ sub LaCrosseGateway_OnConnectTimer($) {
my ($hash) = @_; my ($hash) = @_;
my $name = $hash->{NAME}; my $name = $hash->{NAME};
RemoveInternalTimer($hash, "LaCrosseGateway_OnConnectTimer");
my $attrVal = AttrVal($name, "timeout", undef); my $attrVal = AttrVal($name, "timeout", undef);
if(defined($attrVal)) { if(defined($attrVal)) {
my ($timeout, $interval) = split(',', $attrVal); my ($timeout, $interval) = split(',', $attrVal);
InternalTimer(gettimeofday() + $interval, "LaCrosseGateway_OnConnectTimer", $hash, 0);
my $LaCrosseGatewayTime = InternalVal($name, "${name}_TIME", "2000-01-01 00:00:00"); my $LaCrosseGatewayTime = InternalVal($name, "${name}_TIME", "2000-01-01 00:00:00");
my ($date, $time, $year, $month, $day, $hour, $min, $sec, $timestamp); my ($date, $time, $year, $month, $day, $hour, $min, $sec, $timestamp);
($date, $time) = split( ' ', $LaCrosseGatewayTime); ($date, $time) = split( ' ', $LaCrosseGatewayTime);
@ -444,8 +446,10 @@ sub LaCrosseGateway_OnConnectTimer($) {
$month -= 01; $month -= 01;
$timestamp = timelocal($sec, $min, $hour, $day, $month, $year); $timestamp = timelocal($sec, $min, $hour, $day, $month, $year);
InternalTimer(gettimeofday() + $interval, "LaCrosseGateway_OnConnectTimer", $hash, 0);
if (gettimeofday() - $timestamp > $timeout) { if (gettimeofday() - $timestamp > $timeout) {
return LaCrosseGateway_Connect($hash); return LaCrosseGateway_Connect($hash, 1);
} }
} }
} }