mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-03-03 16:56:54 +00:00
fire events on AD and I2C readings change. Add Windows USB-handling
git-svn-id: https://svn.fhem.de/fhem/trunk@3018 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
7683d7e241
commit
4ba66d7dba
@ -170,6 +170,14 @@ sub FRM_Ready($) {
|
||||
return undef;
|
||||
}
|
||||
return DevIo_OpenDev($hash, 1, "FRM_DoInit") if($hash->{STATE} eq "disconnected");
|
||||
|
||||
# This is relevant for windows/USB only
|
||||
my $po = $hash->{USBDev};
|
||||
my ($BlockingFlags, $InBytes, $OutBytes, $ErrorFlags);
|
||||
if($po) {
|
||||
($BlockingFlags, $InBytes, $OutBytes, $ErrorFlags) = $po->status;
|
||||
}
|
||||
return ($InBytes && $InBytes>0);
|
||||
}
|
||||
|
||||
sub FRM_Attr(@) {
|
||||
@ -430,7 +438,7 @@ sub FRM_i2c_update_device
|
||||
readingsBeginUpdate($hash);
|
||||
$hash->{STATE}="active";
|
||||
readingsBulkUpdate($hash,"values",join (" ",@values),1);
|
||||
readingsEndUpdate($hash,undef);
|
||||
readingsEndUpdate($hash,1);
|
||||
}
|
||||
}
|
||||
|
||||
@ -444,14 +452,26 @@ sub FRM_string_observer
|
||||
sub FRM_poll
|
||||
{
|
||||
my ($hash) = @_;
|
||||
my ($rout, $rin) = ('', '');
|
||||
vec($rin, $hash->{FD}, 1) = 1;
|
||||
my $nfound = select($rout=$rin, undef, undef, 0.1);
|
||||
my $mfound = vec($rout, $hash->{FD}, 1);
|
||||
if($mfound) {
|
||||
$hash->{FirmataDevice}->poll();
|
||||
if (defined $hash->{FD}) {
|
||||
my ($rout, $rin) = ('', '');
|
||||
vec($rin, $hash->{FD}, 1) = 1;
|
||||
my $nfound = select($rout=$rin, undef, undef, 0.1);
|
||||
my $mfound = vec($rout, $hash->{FD}, 1);
|
||||
if($mfound) {
|
||||
$hash->{FirmataDevice}->poll();
|
||||
}
|
||||
return $mfound;
|
||||
} else {
|
||||
# This is relevant for windows/USB only
|
||||
my $po = $hash->{USBDev};
|
||||
my ($BlockingFlags, $InBytes, $OutBytes, $ErrorFlags);
|
||||
if($po) {
|
||||
($BlockingFlags, $InBytes, $OutBytes, $ErrorFlags) = $po->status;
|
||||
}
|
||||
if ($InBytes && $InBytes>0) {
|
||||
$hash->{FirmataDevice}->poll();
|
||||
}
|
||||
}
|
||||
return $mfound;
|
||||
}
|
||||
|
||||
######### following is code to be called from OWX: ##########
|
||||
|
@ -72,8 +72,7 @@ FRM_AD_observer
|
||||
main::readingsBulkUpdate($hash,"alarm-upper-threshold","on",1);
|
||||
}
|
||||
};
|
||||
main::readingsBulkUpdate($hash,"reading",$new, 1);
|
||||
main::readingsEndUpdate($hash,0);
|
||||
main::readingsEndUpdate($hash,1);
|
||||
}
|
||||
|
||||
sub
|
||||
|
Loading…
x
Reference in New Issue
Block a user