mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-01-31 12:49:34 +00:00
add. changes to run FHZ with windows
small cosmetic changes git-svn-id: https://svn.fhem.de/fhem/trunk@187 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
1447051c21
commit
4a7eec6944
@ -70,11 +70,21 @@ FHZ_Initialize($)
|
|||||||
$hash->{SetFn} = "FHZ_Set";
|
$hash->{SetFn} = "FHZ_Set";
|
||||||
$hash->{StateFn} = "FHZ_SetState";
|
$hash->{StateFn} = "FHZ_SetState";
|
||||||
$hash->{ParseFn} = "FHZ_Parse";
|
$hash->{ParseFn} = "FHZ_Parse";
|
||||||
|
$hash->{ReadyFn} = "FHZ_Ready" if ($^O eq 'MSWin32');
|
||||||
$hash->{AttrList}= "do_not_notify:1,0 dummy:1,0 filtertimeout repeater:1,0 " .
|
$hash->{AttrList}= "do_not_notify:1,0 dummy:1,0 filtertimeout repeater:1,0 " .
|
||||||
"showtime:1,0 model:fhz1000,fhz1300 loglevel:0,1,2,3,4,5,6 ".
|
"showtime:1,0 model:fhz1000,fhz1300 loglevel:0,1,2,3,4,5,6 ".
|
||||||
"fhtsoftbuffer:1,0";
|
"fhtsoftbuffer:1,0";
|
||||||
}
|
}
|
||||||
|
#####################################
|
||||||
|
sub
|
||||||
|
FHZ_Ready($$)
|
||||||
|
{
|
||||||
|
my ($hash, $dev) = @_;
|
||||||
|
my $po=$hash->{PortObj};
|
||||||
|
return undef if !$po;
|
||||||
|
my ($BlockingFlags, $InBytes, $OutBytes, $ErrorFlags)=$po->status;
|
||||||
|
return ($InBytes>0);
|
||||||
|
}
|
||||||
#####################################
|
#####################################
|
||||||
sub
|
sub
|
||||||
FHZ_Set($@)
|
FHZ_Set($@)
|
||||||
@ -257,10 +267,13 @@ FHZ_Define($$)
|
|||||||
$po->stty_isig(0);
|
$po->stty_isig(0);
|
||||||
$po->stty_opost(0);
|
$po->stty_opost(0);
|
||||||
$po->stty_icrnl(0);
|
$po->stty_icrnl(0);
|
||||||
|
$po->write_settings;
|
||||||
|
|
||||||
|
|
||||||
$hash->{PortObj} = $po;
|
$hash->{PortObj} = $po;
|
||||||
$hash->{FD} = $po->FILENO;
|
$hash->{FD} = $po->FILENO if !( $^O =~ /Win/ );
|
||||||
|
|
||||||
|
|
||||||
$hash->{DeviceName} = $dev;
|
$hash->{DeviceName} = $dev;
|
||||||
$hash->{PARTIAL} = "";
|
$hash->{PARTIAL} = "";
|
||||||
|
|
||||||
@ -361,15 +374,18 @@ FHZ_ReadAnswer($$)
|
|||||||
return undef if(!$hash || !defined($hash->{FD}));
|
return undef if(!$hash || !defined($hash->{FD}));
|
||||||
|
|
||||||
my ($mfhzdata, $rin) = ("", '');
|
my ($mfhzdata, $rin) = ("", '');
|
||||||
|
my $nfound;
|
||||||
for(;;) {
|
for(;;) {
|
||||||
|
if ($^O eq 'MSWin32') {
|
||||||
|
$nfound=FHZ_Ready($hash,$def);
|
||||||
|
}else{
|
||||||
vec($rin, $hash->{FD}, 1) = 1;
|
vec($rin, $hash->{FD}, 1) = 1;
|
||||||
my $nfound = select($rin, undef, undef, 3); # 3 seconds timeout
|
$nfound = select($rin, undef, undef, 3); # 3 seconds timeout
|
||||||
if($nfound < 0) {
|
if($nfound < 0) {
|
||||||
next if ($! == EAGAIN() || $! == EINTR() || $! == 0);
|
next if ($! == EAGAIN() || $! == EINTR() || $! == 0);
|
||||||
die("Select error $nfound / $!\n");
|
die("Select error $nfound / $!\n");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return "Timeout reading answer for get $arg" if($nfound == 0);
|
return "Timeout reading answer for get $arg" if($nfound == 0);
|
||||||
|
|
||||||
my $buf = $hash->{PortObj}->input();
|
my $buf = $hash->{PortObj}->input();
|
||||||
@ -520,10 +536,15 @@ FHZ_Read($)
|
|||||||
$hash->{PortObj}->close();
|
$hash->{PortObj}->close();
|
||||||
for(;;) {
|
for(;;) {
|
||||||
sleep(5);
|
sleep(5);
|
||||||
|
if ($^O eq 'MSWin32') {
|
||||||
|
$hash->{PortObj} = new Win32::SerialPort($devname);
|
||||||
|
}else{
|
||||||
$hash->{PortObj} = new Device::SerialPort($devname);
|
$hash->{PortObj} = new Device::SerialPort($devname);
|
||||||
|
}
|
||||||
|
|
||||||
if($hash->{PortObj}) {
|
if($hash->{PortObj}) {
|
||||||
Log 1, "USB device $devname reappeared";
|
Log 1, "USB device $devname reappeared";
|
||||||
$hash->{FD} = $hash->{PortObj}->FILENO;
|
$hash->{FD} = $hash->{PortObj}->FILENO if !($^O eq 'MSWin32');
|
||||||
DoInit($name);
|
DoInit($name);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -600,7 +621,7 @@ FHZ_Read($)
|
|||||||
my @found;
|
my @found;
|
||||||
my $last_module;
|
my $last_module;
|
||||||
foreach my $m (sort { $modules{$a}{ORDER} cmp $modules{$b}{ORDER} }
|
foreach my $m (sort { $modules{$a}{ORDER} cmp $modules{$b}{ORDER} }
|
||||||
keys %modules) {
|
grep {defined($modules{$_}{ORDER});}keys %modules) {
|
||||||
next if($iohash->{Clients} !~ m/:$m:/);
|
next if($iohash->{Clients} !~ m/:$m:/);
|
||||||
next if($dmsg !~ m/$modules{$m}{Match}/i);
|
next if($dmsg !~ m/$modules{$m}{Match}/i);
|
||||||
no strict "refs";
|
no strict "refs";
|
||||||
|
Loading…
Reference in New Issue
Block a user