switched to log3

git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@3840 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
justme-1968 2013-09-02 19:28:43 +00:00
parent 75ee8464d8
commit 0e8effa5f7
3 changed files with 33 additions and 30 deletions

View File

@ -17,7 +17,7 @@ SYSSTAT_Initialize($)
$hash->{UndefFn} = "SYSSTAT_Undefine"; $hash->{UndefFn} = "SYSSTAT_Undefine";
$hash->{GetFn} = "SYSSTAT_Get"; $hash->{GetFn} = "SYSSTAT_Get";
$hash->{AttrFn} = "SYSSTAT_Attr"; $hash->{AttrFn} = "SYSSTAT_Attr";
$hash->{AttrList} = "filesystems raspberrycpufreq:1 raspberrytemperature:0,1,2 showpercent:1 uptime:1,2 useregex:1 ssh_user loglevel:0,1,2,3,4,5,6 ". $hash->{AttrList} = "filesystems raspberrycpufreq:1 raspberrytemperature:0,1,2 showpercent:1 uptime:1,2 useregex:1 ssh_user ".
$readingFnAttributes; $readingFnAttributes;
} }

View File

@ -84,10 +84,10 @@ SWAP_Initialize($)
$hash->{FingerprintFn} = "SWAP_Fingerprint"; $hash->{FingerprintFn} = "SWAP_Fingerprint";
$hash->{ParseFn} = "SWAP_Parse"; $hash->{ParseFn} = "SWAP_Parse";
$hash->{AttrFn} = "SWAP_Attr"; $hash->{AttrFn} = "SWAP_Attr";
$hash->{AttrList} = "IODev ". $hash->{AttrList} = "IODev".
"ignore:1,0 ". " ignore:1,0".
"loglevel:0,1,2,3,4,5,6 $readingFnAttributes " . " $readingFnAttributes" .
"ProductCode:".join(",", sort keys %{$products}); " ProductCode:".join(",", sort keys %{$products});
#$hash->{FW_summaryFn} = "SWAP_summaryFn"; #$hash->{FW_summaryFn} = "SWAP_summaryFn";
} }
@ -101,7 +101,7 @@ SWAP_loadDevices()
my $file_name = "$attr{global}{modpath}/FHEM/lib/SWAP/devices.xml"; my $file_name = "$attr{global}{modpath}/FHEM/lib/SWAP/devices.xml";
if( ! -e $file_name ){ if( ! -e $file_name ){
Log 2, "could not read $file_name"; Log3 undef, 2, "could not read $file_name";
return ($_developers,$_products); return ($_developers,$_products);
} }
@ -141,7 +141,7 @@ readDeviceXML($$)
if( ! -e $file_name ) { if( ! -e $file_name ) {
$product = undef; $product = undef;
Log 2, "could not read $file_name"; Log3 undef, 2, "could not read $file_name";
return; return;
} }
@ -206,7 +206,7 @@ SWAP_Define($$)
if(@a != 3 && @a != 4 ) { if(@a != 3 && @a != 4 ) {
my $msg = "wrong syntax: define <name> SWAP <addr>[.<reg>] [<ProductCode>]"; my $msg = "wrong syntax: define <name> SWAP <addr>[.<reg>] [<ProductCode>]";
Log 2, $msg; Log3 undef, 2, $msg;
return $msg; return $msg;
} }
@ -249,9 +249,9 @@ SWAP_Define($$)
AssignIoPort($hash); AssignIoPort($hash);
$hash->{TYPE} = $type; $hash->{TYPE} = $type;
if(defined($hash->{IODev}->{NAME})) { if(defined($hash->{IODev}->{NAME})) {
Log 3, "$name: I/O device is " . $hash->{IODev}->{NAME}; Log3 $name, 3, "$name: I/O device is " . $hash->{IODev}->{NAME};
} else { } else {
Log 1, "$name: no I/O device"; Log3 $name, 1, "$name: no I/O device";
} }
CommandAttr(undef, "$name ProductCode $productcode") if( $productcode ); CommandAttr(undef, "$name ProductCode $productcode") if( $productcode );
@ -302,7 +302,6 @@ SWAP_Set($@)
my $arg = $aa[1]; my $arg = $aa[1];
my $arg2 = $aa[2]; my $arg2 = $aa[2];
my $arg3 = $aa[3]; my $arg3 = $aa[3];
my $ll = GetLogLevel($name,3);
my $list = "regGet regSet"; my $list = "regGet regSet";
$list .= " statusRequest:noArg"; $list .= " statusRequest:noArg";
@ -700,7 +699,7 @@ SWAP_readDeviceXML($$)
if( defined($developer->{name}) && defined($product->{name}) ) { if( defined($developer->{name}) && defined($product->{name}) ) {
readDeviceXML( $products->{$productcode}, "$attr{global}{modpath}/FHEM/lib/SWAP/$developer->{name}/$product->{name}.xml" ); readDeviceXML( $products->{$productcode}, "$attr{global}{modpath}/FHEM/lib/SWAP/$developer->{name}/$product->{name}.xml" );
} else { } else {
Log 2, "no device xml found for productcode $productcode"; Log3 $hash->{NAME}, 2, "no device xml found for productcode $productcode";
} }
} }
@ -773,6 +772,7 @@ sub
SWAP_Parse($$) SWAP_Parse($$)
{ {
my ($hash, $msg) = @_; my ($hash, $msg) = @_;
my $name = $hash->{NAME};
return undef if( $msg !~ m/^[\dA-F]{12,}$/ ); return undef if( $msg !~ m/^[\dA-F]{12,}$/ );
@ -804,7 +804,7 @@ SWAP_Parse($$)
if( $reg == 0x09 if( $reg == 0x09
&& $func == STATUS && $func == STATUS
&& $raddr ne $data ) { && $raddr ne $data ) {
Log 4, "addr change: ". $raddr ." -> ". $data; Log3 $name, 4, "addr change: ". $raddr ." -> ". $data;
if( defined( $modules{SWAP}{defptr}{$raddr} ) ) { if( defined( $modules{SWAP}{defptr}{$raddr} ) ) {
delete( $modules{SWAP}{defptr}{$raddr} ); delete( $modules{SWAP}{defptr}{$raddr} );
@ -825,17 +825,17 @@ SWAP_Parse($$)
if( defined($rhash->{SWAP_nonce}) if( defined($rhash->{SWAP_nonce})
&& hex($nonce) == hex($rhash->{SWAP_nonce}) ) { && hex($nonce) == hex($rhash->{SWAP_nonce}) ) {
Log 4, "DUP: ". $sname ." -> ". $dname ." ($hop,$secu-$nonce): ". $function_codes{$func} . " ". $rname . " ". $regname . ($data?":":"") . $data; Log3 $name, 4, "DUP: ". $sname ." -> ". $dname ." ($hop,$secu-$nonce): ". $function_codes{$func} . " ". $rname . " ". $regname . ($data?":":"") . $data;
return $rname; return $rname;
} }
Log 4, $sname ." -> ". $dname ." ($hop,$secu-$nonce): ". $function_codes{$func} . " ". $rname . " ". $regname . ($data?":":"") . $data; Log3 $name, 4, $sname ." -> ". $dname ." ($hop,$secu-$nonce): ". $function_codes{$func} . " ". $rname . " ". $regname . ($data?":":"") . $data;
return $rname if( $raddr eq "01" ); return $rname if( $raddr eq "01" );
return $rname if( $func == QUERY ); return $rname if( $func == QUERY );
if( !$modules{SWAP}{defptr}{$raddr} ) { if( !$modules{SWAP}{defptr}{$raddr} ) {
Log 3, "SWAP Unknown device $rname, please define it"; Log3 $name, 3, "SWAP Unknown device $rname, please define it";
return undef if( $raddr eq "00" ); return undef if( $raddr eq "00" );
$rname = SWAP_findFreeAddress($hash,$raddr) if( $raddr eq "FF" ); #use next free addr as name -> consistent name after change below $rname = SWAP_findFreeAddress($hash,$raddr) if( $raddr eq "FF" ); #use next free addr as name -> consistent name after change below
@ -892,13 +892,13 @@ SWAP_Parse($$)
&& $data eq "FF" ) { && $data eq "FF" ) {
my $addr = SWAP_findFreeAddress($hash,$data); my $addr = SWAP_findFreeAddress($hash,$data);
if( $addr ne $data ) { if( $addr ne $data ) {
Log 3, "SWAP $rname: changing 09-DeviceAddress from default $data to $addr"; Log3 $rname, 3, "SWAP $rname: changing 09-DeviceAddress from default $data to $addr";
SWAP_Set( $rhash, $rname, "regSet", "09", "$addr" ); #device should already have consistent name from autocreate above SWAP_Set( $rhash, $rname, "regSet", "09", "$addr" ); #device should already have consistent name from autocreate above
} }
} elsif( $reg == 0x0A } elsif( $reg == 0x0A
&& $data eq "FFFF" && $data eq "FFFF"
&& $rhash->{product}->{pwrdownmode} == 1 ) { && $rhash->{product}->{pwrdownmode} == 1 ) {
Log 3, "SWAP $rname: changing 0A-PeriodicTxInterval from default FFFF to 0384 (900 seconds)"; Log3 $rname, 3, "SWAP $rname: changing 0A-PeriodicTxInterval from default FFFF to 0384 (900 seconds)";
SWAP_Set( $rhash, $rname, "regSet", "0A", "0384" ); SWAP_Set( $rhash, $rname, "regSet", "0A", "0384" );
} }

View File

@ -43,7 +43,7 @@ panStamp_Initialize($)
#$hash->{GetFn} = "panStamp_Get"; #$hash->{GetFn} = "panStamp_Get";
$hash->{SetFn} = "panStamp_Set"; $hash->{SetFn} = "panStamp_Set";
#$hash->{AttrFn} = "panStamp_Attr"; #$hash->{AttrFn} = "panStamp_Attr";
$hash->{AttrList}= "model:panStamp loglevel:0,1,2,3,4,5,6"; #$hash->{AttrList}= "";
$hash->{ShutdownFn} = "panStamp_Shutdown"; $hash->{ShutdownFn} = "panStamp_Shutdown";
} }
@ -62,7 +62,7 @@ panStamp_Define($$)
if(@a < 3 || @a > 6) { if(@a < 3 || @a > 6) {
my $msg = "wrong syntax: define <name> panStamp {devicename[\@baudrate] ". my $msg = "wrong syntax: define <name> panStamp {devicename[\@baudrate] ".
"| devicename\@directio} [<address> [<channel> [<syncword>]]]"; "| devicename\@directio} [<address> [<channel> [<syncword>]]]";
Log 2, $msg; Log3 undef, 2, $msg;
return $msg; return $msg;
} }
@ -81,7 +81,9 @@ panStamp_Define($$)
DevIo_CloseDev($hash); DevIo_CloseDev($hash);
my $name = $a[0]; my $name = $a[0];
my $dev = $a[2]; my $dev = $a[2];
$dev .= "\@38400" if( $dev !~ m/\@/ );
$hash->{address} = uc($address); $hash->{address} = uc($address);
$hash->{channel} = uc($channel); $hash->{channel} = uc($channel);
@ -111,7 +113,7 @@ panStamp_Undef($$)
$defs{$d}{IODev} == $hash) $defs{$d}{IODev} == $hash)
{ {
my $lev = ($reread_active ? 4 : 2); my $lev = ($reread_active ? 4 : 2);
Log GetLogLevel($name,$lev), "deleting port for $d"; Log3 $name, $lev, "deleting port for $d";
delete $defs{$d}{IODev}; delete $defs{$d}{IODev};
} }
} }
@ -146,11 +148,11 @@ panStamp_Set($@)
if($cmd eq "raw") { if($cmd eq "raw") {
return "\"set panStamp $cmd\" needs exactly one parameter" if(@_ != 4); return "\"set panStamp $cmd\" needs exactly one parameter" if(@_ != 4);
return "Expecting a even length hex number" if((length($arg)&1) == 1 || $arg !~ m/^[\dA-F]{12,}$/ ); return "Expecting a even length hex number" if((length($arg)&1) == 1 || $arg !~ m/^[\dA-F]{12,}$/ );
Log GetLogLevel($name,4), "set $name $cmd $arg"; Log3 $name, 4, "set $name $cmd $arg";
panStamp_SimpleWrite($hash, $arg); panStamp_SimpleWrite($hash, $arg);
} elsif($cmd eq "discover") { } elsif($cmd eq "discover") {
Log GetLogLevel($name,4), "set $name $cmd"; Log3 $name, 4, "set $name $cmd";
panStamp_SimpleWrite($hash, "00".$hash->{address}."0000010000" ); panStamp_SimpleWrite($hash, "00".$hash->{address}."0000010000" );
} else { } else {
@ -297,7 +299,7 @@ panStamp_ReadAnswer($$$$)
} }
if($buf) { if($buf) {
Log 5, "panStamp/RAW (ReadAnswer): $buf"; Log3 $hash->{NAME}, 5, "panStamp/RAW (ReadAnswer): $buf";
$mpandata .= $buf; $mpandata .= $buf;
} }
@ -329,7 +331,7 @@ panStamp_XmitLimitCheck($$)
if(@b > 163) { # 163 comes from fs20. todo: verify if correct for panstamp modulation if(@b > 163) { # 163 comes from fs20. todo: verify if correct for panstamp modulation
my $name = $hash->{NAME}; my $name = $hash->{NAME};
Log GetLogLevel($name,2), "panStamp TRANSMIT LIMIT EXCEEDED"; Log3 $name, 2, "panStamp TRANSMIT LIMIT EXCEEDED";
DoTrigger($name, "TRANSMIT LIMIT EXCEEDED"); DoTrigger($name, "TRANSMIT LIMIT EXCEEDED");
} else { } else {
@ -346,8 +348,10 @@ sub
panStamp_Write($$$) panStamp_Write($$$)
{ {
my ($hash,$addr,$msg) = @_; my ($hash,$addr,$msg) = @_;
my $name = $hash->{NAME};
Log3 $name, 5, "$name sending $msg";
Log 5, "$hash->{NAME} sending $addr $msg";
my $bstring = $addr.$hash->{address}.$msg; my $bstring = $addr.$hash->{address}.$msg;
panStamp_AddQueue($hash, $bstring); panStamp_AddQueue($hash, $bstring);
@ -432,7 +436,7 @@ panStamp_Read($)
my $name = $hash->{NAME}; my $name = $hash->{NAME};
my $pandata = $hash->{PARTIAL}; my $pandata = $hash->{PARTIAL};
Log 5, "panStamp/RAW: $pandata/$buf"; Log3 $name, 5, "panStamp/RAW: $pandata/$buf";
$pandata .= $buf; $pandata .= $buf;
while($pandata =~ m/\n/) { while($pandata =~ m/\n/) {
@ -455,7 +459,7 @@ panStamp_Parse($$$$)
$rssi = ($rssi>=128 ? (($rssi-256)/2-74) : ($rssi/2-74)); $rssi = ($rssi>=128 ? (($rssi-256)/2-74) : ($rssi/2-74));
my $lqi = hex(substr($dmsg, 3, 2)); my $lqi = hex(substr($dmsg, 3, 2));
$dmsg = substr($dmsg, 6, $l-6); $dmsg = substr($dmsg, 6, $l-6);
Log GetLogLevel($name,5), "$name: $dmsg $rssi $lqi"; Log3 $name, 5, "$name: $dmsg $rssi $lqi";
next if(!$dmsg || length($dmsg) < 1); # Bogus messages next if(!$dmsg || length($dmsg) < 1); # Bogus messages
@ -501,8 +505,7 @@ panStamp_SimpleWrite(@)
return if(!$hash); return if(!$hash);
my $name = $hash->{NAME}; my $name = $hash->{NAME};
my $ll5 = GetLogLevel($name,5); Log3 $name, 5, "SW: $msg";
Log $ll5, "SW: $msg";
$msg .= "\r" unless($nocr); $msg .= "\r" unless($nocr);