mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-02-07 16:59:18 +00:00
DevIo.pm: implement noDevIoSTATE (Forum #120940)
git-svn-id: https://svn.fhem.de/fhem/trunk@24594 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
dc2642407a
commit
f4a323ca4b
@ -208,6 +208,7 @@ CUL_Define($$)
|
||||
$hash->{CMDS} = "";
|
||||
$hash->{Clients} = $clientsSlowRF;
|
||||
$hash->{MatchList} = \%matchListSlowRF;
|
||||
$hash->{noDevIoSTATE} = 1;
|
||||
|
||||
if($dev eq "none") {
|
||||
Log3 $name, 1, "$name device is none, commands will be echoed only";
|
||||
@ -962,7 +963,7 @@ CUL_Ready($)
|
||||
my ($hash) = @_;
|
||||
|
||||
return DevIo_OpenDev($hash, 1, "CUL_DoInit", sub(){})
|
||||
if($hash->{STATE} eq "disconnected");
|
||||
if(DevIo_getState($hash) eq "disconnected");
|
||||
|
||||
# This is relevant for windows/USB only
|
||||
my $po = $hash->{USBDev};
|
||||
|
@ -4,6 +4,7 @@ package main;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use DevIo;
|
||||
use Time::HiRes qw(gettimeofday);
|
||||
|
||||
sub FBAHA_Read($@);
|
||||
@ -19,8 +20,6 @@ FBAHA_Initialize($)
|
||||
{
|
||||
my ($hash) = @_;
|
||||
|
||||
require "$attr{global}{modpath}/FHEM/DevIo.pm";
|
||||
|
||||
# Provider
|
||||
$hash->{ReadFn} = "FBAHA_Read";
|
||||
$hash->{WriteFn} = "FBAHA_Write";
|
||||
@ -54,6 +53,7 @@ FBAHA_Define($$)
|
||||
$hash->{Clients} = ":FBDECT:";
|
||||
my %matchList = ( "1:FBDECT" => ".*" );
|
||||
$hash->{MatchList} = \%matchList;
|
||||
$hash->{noDevIoSTATE} = 1;
|
||||
|
||||
DevIo_CloseDev($hash);
|
||||
$hash->{DeviceName} = $dev;
|
||||
@ -396,7 +396,7 @@ FBAHA_Ready($)
|
||||
my ($hash) = @_;
|
||||
|
||||
return DevIo_OpenDev($hash, 1, "FBAHA_DoInit")
|
||||
if($hash->{STATE} eq "disconnected");
|
||||
if(DevIo_getState($hash) eq "disconnected");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -97,7 +97,7 @@ MQTT2_CLIENT_connect($)
|
||||
{
|
||||
my ($hash) = @_;
|
||||
return if($hash->{authError});
|
||||
my $disco = (ReadingsVal($hash->{NAME}, "state", "") eq "disconnected");
|
||||
my $disco = (DevIo_getState($hash) eq "disconnected");
|
||||
$hash->{connecting} = 1 if($disco && !$hash->{connecting});
|
||||
$hash->{nextOpenDelay} = 5;
|
||||
$hash->{BUF}="";
|
||||
|
@ -92,6 +92,7 @@ ZWCUL_Define($$)
|
||||
my %matchList = ( "1:ZWave" => "^[0-9A-Fa-f]+\$",
|
||||
"2:STACKABLE"=>"^\\*" );
|
||||
$hash->{MatchList} = \%matchList;
|
||||
$hash->{noDevIoSTATE} = 1;
|
||||
|
||||
if($dev eq "none") {
|
||||
Log3 $name, 1, "$name device is none, commands will be echoed only";
|
||||
@ -629,7 +630,7 @@ ZWCUL_Ready($)
|
||||
return undef if (IsDisabled($hash->{NAME}));
|
||||
|
||||
return DevIo_OpenDev($hash, 1, "ZWCUL_DoInit")
|
||||
if(ReadingsVal($hash->{NAME}, "state","") eq "disconnected");
|
||||
if(DevIo_getState($hash) eq "disconnected");
|
||||
|
||||
# This is relevant for windows/USB only
|
||||
my $po = $hash->{USBDev};
|
||||
|
@ -154,6 +154,7 @@ ZWDongle_Define($$)
|
||||
$hash->{DeviceName} = $dev;
|
||||
$hash->{CallbackNr} = 0;
|
||||
$hash->{nrNAck} = 0;
|
||||
$hash->{noDevIoSTATE} = 1;
|
||||
my @empty;
|
||||
$hash->{SendStack} = \@empty;
|
||||
ZWDongle_shiftSendStack($hash, 0, 5, undef); # Init variables
|
||||
@ -1033,7 +1034,7 @@ ZWDongle_Ready($)
|
||||
return undef if (IsDisabled($hash->{NAME}));
|
||||
|
||||
return DevIo_OpenDev($hash, 1, "ZWDongle_DoInit")
|
||||
if(ReadingsVal($hash->{NAME}, "state","") eq "disconnected");
|
||||
if(DevIo_getState($hash) eq "disconnected");
|
||||
|
||||
# This is relevant for windows/USB only
|
||||
my $po = $hash->{USBDev};
|
||||
|
@ -19,8 +19,19 @@ sub
|
||||
DevIo_setStates($$)
|
||||
{
|
||||
my ($hash, $val) = @_;
|
||||
$hash->{STATE} = $val;
|
||||
setReadingsVal($hash, "state", $val, TimeNow());
|
||||
if($hash->{noDevIoSTATE}) {
|
||||
evalStateFormat($hash);
|
||||
} else {
|
||||
$hash->{STATE} = $val;
|
||||
}
|
||||
}
|
||||
|
||||
sub
|
||||
DevIo_getState($)
|
||||
{
|
||||
my ($hash) = @_;
|
||||
return ReadingsVal($hash->{NAME}, "state", "")
|
||||
}
|
||||
|
||||
########################
|
||||
@ -281,7 +292,7 @@ DevIo_Expect($$$)
|
||||
my ($hash, $msg, $timeout) = @_;
|
||||
my $name= $hash->{NAME};
|
||||
|
||||
my $state= $hash->{STATE};
|
||||
my $state= DevIo_getState($hash);
|
||||
if($state ne "opened") {
|
||||
Log3 $name, 2, "Attempt to write to $state device.";
|
||||
return undef;
|
||||
|
Loading…
x
Reference in New Issue
Block a user