diff --git a/fhem/CHANGED b/fhem/CHANGED index 6dd1ffc0d..3c5d970e2 100644 --- a/fhem/CHANGED +++ b/fhem/CHANGED @@ -225,7 +225,7 @@ - filelogs will additionally be notified on set or trigger commands - the extra_notify flag is gone: it is default now, there is a do_not_notify flag for the opposite behaviour. - - feature: at timespec as a function. Example: at +*{sunset()} + - feature: at timespec as a function. Example: at +*{sunset()} commandref.html and examples revisited. - feature: 99_SUNRISE.pm added to use with the new at functionality (replaces the old 99_SUNSET.pm) @@ -434,3 +434,4 @@ - feature: add timestamp to inform - feature: The strange stty settings in 00_FHEM.pm are optional - bugfix: webpgm2 iPhone fix + - feature: fullinit and reopen commands for FHZ added (Boris 2008-11-01) diff --git a/fhem/FHEM/00_FHZ.pm b/fhem/FHEM/00_FHZ.pm index d69155a76..c8ef2eaf6 100755 --- a/fhem/FHEM/00_FHZ.pm +++ b/fhem/FHEM/00_FHZ.pm @@ -30,6 +30,8 @@ my %sets = ( "activefor"=> "xx xx", "raw" => "xx xx", + "initfull" => "xx xx", + "reopen" => "xx xx", ); my %setnrparam = ( "time" => 0, @@ -38,6 +40,8 @@ my %setnrparam = ( "FHTcode" => 1, "activefor"=> 1, "raw" => 2, + "initfull" => 0, + "reopen" => 0, ); my %codes = ( @@ -74,7 +78,7 @@ FHZ_Initialize($) $hash->{StateFn} = "FHZ_SetState"; $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 ". - "fhtsoftbuffer:1,0"; + "fhtsoftbuffer:1,0"; } ##################################### sub @@ -117,6 +121,21 @@ FHZ_Set($@) $dhash->{IODev} = $hash; return undef; + } elsif($a[1] eq "initfull") { + + my @init; + push(@init, "get $name init2"); + push(@init, "get $name serial"); + push(@init, "set $name initHMS"); + push(@init, "set $name initFS20"); + push(@init, "set $name time"); + push(@init, "set $name raw 04 01010100010000"); + CommandChain(3, \@init); + + } elsif($a[1] eq "reopen") { + + FHZ_Reopen($hash); + } elsif($a[1] eq "raw") { $fn = $a[2]; @@ -266,7 +285,7 @@ FHZ_Define($$) $attr{$name}{dummy} = 1; return undef; } - + Log 3, "FHZ opening FHZ device $dev"; if ($^O=~/Win/) { require Win32::SerialPort; @@ -429,7 +448,7 @@ FHZ_CompleteMsg($$) return pack('C*', 0x81, $len/2+2, ord(pack('H*',$fn)), FHZ_Crc(@data), @data); } - + ##################################### # Check if the 1% limit is reached and trigger notifies sub @@ -525,6 +544,31 @@ FHZ_HandleWriteQueue($) } } +##################################### +sub +FHZ_Reopen($) +{ + my ($hash) = @_; + + my $devname = $hash->{DeviceName}; + $hash->{PortObj}->close(); + Log 1, "USB device $devname closed"; + for(;;) { + sleep(5); + if ($^O eq 'MSWin32') { + $hash->{PortObj} = new Win32::SerialPort($devname); + }else{ + $hash->{PortObj} = new Device::SerialPort($devname); + } + if($hash->{PortObj}) { + Log 1, "USB device $devname reopened"; + $hash->{FD} = $hash->{PortObj}->FILENO if !($^O eq 'MSWin32'); + DoInit($hash->{NAME}, $hash->{ttytype}, $hash->{PortObj}); + return; + } + } +} + ##################################### sub FHZ_Read($) @@ -551,9 +595,9 @@ FHZ_Read($) 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}) { Log 1, "USB device $devname reappeared"; $hash->{FD} = $hash->{PortObj}->FILENO if !($^O eq 'MSWin32'); diff --git a/fhem/HISTORY b/fhem/HISTORY index 456a339be..90a0a9e09 100644 --- a/fhem/HISTORY +++ b/fhem/HISTORY @@ -122,8 +122,8 @@ - Rudi Sun Aug 5 10:59:51 MEST 2007 - WS300 Loglevel changed for KS300 device (from 2 to GetLogLevel or 5) - - First version of the FritzBox port: - - Perl binary/ftdi_sio module + - First version of the FritzBox port: + - Perl binary/ftdi_sio module - EM: added setTime, reset - docs/fritzbox.html. Note: The fb_fhem_0.1.tar.gz won't be part of CVS as it contains largee binaries (swapfile, perl mipsel executable, etc). @@ -187,7 +187,7 @@ One step closer for complete fhem on the FritzBox. - Boris Sun Jan 06 13:35:00 CET 2008 - - bugfix: 62_EMEM.pm: changed reading energy_total_kWh to energy_kWh_w, + - bugfix: 62_EMEM.pm: changed reading energy_total_kWh to energy_kWh_w, added energy_kWh (formerly energy_total_kWh) - changed em1010.pl accordingly, added em1000em doc for getDevStatus reply from device @@ -213,7 +213,7 @@ - Rudi Sun Jan 27 18:12:42 MET 2008 - em1010PC: sending a "67" after a reset skips the manual interaction: - automatic reset is now possible. + automatic reset is now possible. - Peter S. Sat Feb 16 22:22:21 MET 2008 - linux.html: Note on kernel 2.6.24.2 (includes our changes) @@ -313,3 +313,7 @@ Fri Jul 25 18:14:26 MEST 2008 these are considered "utility" modules and are loaded at the beginning. Some of the older 99_x modules were renamed (99_SVG, 99_dummy), and most contrib modules were moved to the main FHEM directory. + +- Boris Sat Nov 01 CET 2008 + - feature: new commands fullinit and reopen for FHZ, commandref.html update +