mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-02-01 01:09:47 +00:00
44_TEK603: Added patch for TEK603 not prevent FHEM start if USB device is not reachable and change to use DevIo
git-svn-id: https://svn.fhem.de/fhem/trunk@22136 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
b6c57b6cc5
commit
21c22f517b
@ -27,6 +27,7 @@ package main;
|
|||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
|
use DevIo;
|
||||||
|
|
||||||
use Digest::CRC; # libdigest-crc-perl
|
use Digest::CRC; # libdigest-crc-perl
|
||||||
|
|
||||||
@ -42,8 +43,6 @@ sub TEK603_reconnect($);
|
|||||||
sub TEK603_Initialize($) {
|
sub TEK603_Initialize($) {
|
||||||
my ($hash) = @_;
|
my ($hash) = @_;
|
||||||
|
|
||||||
require $attr{global}{modpath} . '/FHEM/DevIo.pm';
|
|
||||||
|
|
||||||
$hash->{ReadFn} = 'TEK603_read';
|
$hash->{ReadFn} = 'TEK603_read';
|
||||||
$hash->{ReadyFn} = 'TEK603_ready';
|
$hash->{ReadyFn} = 'TEK603_ready';
|
||||||
$hash->{DefFn} = 'TEK603_define';
|
$hash->{DefFn} = 'TEK603_define';
|
||||||
@ -139,16 +138,28 @@ sub TEK603_undef($$) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
sub TEK603_ready($) {
|
sub TEK603_ready() {
|
||||||
my ($hash) = @_;
|
my ($hash) = @_;
|
||||||
my $name = $hash->{NAME};
|
my $name = $hash->{NAME};
|
||||||
return if (IsDisabled($name));
|
return if (IsDisabled($name));
|
||||||
return DevIo_OpenDev($hash, 1, 'TEK603_doInit') if($hash->{STATE} eq 'disconnected');
|
return DevIo_OpenDev($hash, 1, 'TEK603_doInit') if($hash->{STATE} eq 'disconnected');
|
||||||
|
|
||||||
# This is relevant for windows/USB only
|
# This is relevant for windows/USB only
|
||||||
|
my ($BlockingFlags, $InBytes, $OutBytes, $ErrorFlags);
|
||||||
my $po = $hash->{USBDev};
|
my $po = $hash->{USBDev};
|
||||||
my ($BlockingFlags, $InBytes, $OutBytes, $ErrorFlags) = $po->status;
|
|
||||||
return ($InBytes > 0);
|
if ($po) {
|
||||||
|
($BlockingFlags, $InBytes, $OutBytes, $ErrorFlags) = $po->status;
|
||||||
|
return ($InBytes > 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
# Someone set us up the bomb
|
||||||
|
Log3($hash->{NAME}, 1, qq[Can't read from $hash->{DeviceName}]);
|
||||||
|
|
||||||
|
# disable device
|
||||||
|
Log3($hash->{NAME}, 1, qq[Disabled device due read errors]);
|
||||||
|
CommandAttr(undef, $hash->{NAME} . ' disable 1');
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub TEK603_read($) {
|
sub TEK603_read($) {
|
||||||
|
Loading…
Reference in New Issue
Block a user