mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-04-16 10:46:03 +00:00
open/close by Holger
git-svn-id: https://svn.fhem.de/fhem/trunk@795 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
254365650b
commit
659a54ef74
@ -48,6 +48,9 @@ my %sets = (
|
||||
"raw" => "xx xx",
|
||||
"initfull" => "xx xx",
|
||||
"reopen" => "xx xx",
|
||||
"close" => "xx xx",
|
||||
"open" => "xx xx",
|
||||
|
||||
);
|
||||
my %setnrparam = (
|
||||
"time" => 0,
|
||||
@ -59,6 +62,9 @@ my %setnrparam = (
|
||||
"raw" => 2,
|
||||
"initfull" => 0,
|
||||
"reopen" => 0,
|
||||
"close" => 0,
|
||||
"open" => 0,
|
||||
|
||||
);
|
||||
|
||||
my %codes = (
|
||||
@ -179,6 +185,16 @@ FHZ_Set($@)
|
||||
FHZ_Reopen($hash);
|
||||
return undef;
|
||||
|
||||
} elsif($a[1] eq "close") {
|
||||
|
||||
FHZ_Close($hash);
|
||||
return undef;
|
||||
|
||||
} elsif($a[1] eq "open") {
|
||||
|
||||
FHZ_Open($hash);
|
||||
return undef;
|
||||
|
||||
} elsif($a[1] eq "raw") {
|
||||
|
||||
$fn = $a[2];
|
||||
@ -637,6 +653,55 @@ FHZ_Reopen($)
|
||||
}
|
||||
}
|
||||
|
||||
#####################################
|
||||
sub
|
||||
FHZ_Close($)
|
||||
{
|
||||
my ($hash) = @_;
|
||||
|
||||
my $dev = $hash->{DeviceName};
|
||||
return if(!$dev);
|
||||
my $name = $hash->{NAME};
|
||||
|
||||
$hash->{PortObj}->close();
|
||||
Log 1, "USB device $dev closed";
|
||||
delete($hash->{PortObj});
|
||||
delete($hash->{FD});
|
||||
delete($selectlist{"$name.$dev"});
|
||||
#$readyfnlist{"$name.$dev"} = $hash; # Start polling
|
||||
$hash->{STATE} = "disconnected";
|
||||
|
||||
|
||||
# Without the following sleep the open of the device causes a SIGSEGV,
|
||||
# and following opens block infinitely. Only a reboot helps.
|
||||
sleep(5);
|
||||
|
||||
DoTrigger($name, "DISCONNECTED");
|
||||
|
||||
}
|
||||
|
||||
#####################################
|
||||
sub
|
||||
FHZ_Open($)
|
||||
{
|
||||
my ($hash) = @_;
|
||||
|
||||
my $dev = $hash->{DeviceName};
|
||||
return if(!$dev);
|
||||
my $name = $hash->{NAME};
|
||||
|
||||
$readyfnlist{"$name.$dev"} = $hash; # Start polling
|
||||
$hash->{STATE} = "disconnected";
|
||||
|
||||
|
||||
# Without the following sleep the open of the device causes a SIGSEGV,
|
||||
# and following opens block infinitely. Only a reboot helps.
|
||||
sleep(5);
|
||||
|
||||
DoTrigger($name, "DISCONNECTED");
|
||||
|
||||
}
|
||||
|
||||
#####################################
|
||||
sub
|
||||
FHZ_Read($)
|
||||
|
Loading…
x
Reference in New Issue
Block a user