2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-04-07 19:04:20 +00:00

Log migrated to Log3

git-svn-id: https://svn.fhem.de/fhem/trunk@3830 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
borisneubert 2013-08-31 17:09:10 +00:00
parent 401b3e4ad9
commit 1ca00a2342
13 changed files with 151 additions and 200 deletions

View File

@ -102,7 +102,7 @@ CM11_Initialize($)
$hash->{SetFn} = "CM11_Set"; $hash->{SetFn} = "CM11_Set";
$hash->{StateFn} = "CM11_SetState"; $hash->{StateFn} = "CM11_SetState";
$hash->{AttrList}= "do_not_notify:1,0 dummy:1,0 " . $hash->{AttrList}= "do_not_notify:1,0 dummy:1,0 " .
"model:CM11 loglevel:0,1,2,3,4,5,6"; "model:CM11";
} }
##################################### #####################################
sub sub
@ -152,7 +152,6 @@ CM11_Reopen($)
my $name = $hash->{NAME}; my $name = $hash->{NAME};
my $dev = $hash->{DeviceName}; my $dev = $hash->{DeviceName};
$hash->{PortObj}->close(); $hash->{PortObj}->close();
# Log 1, "Device $dev closed";
Log3($name, 1, "Device $dev closed"); Log3($name, 1, "Device $dev closed");
for(;;) { for(;;) {
sleep(5); sleep(5);
@ -162,7 +161,6 @@ CM11_Reopen($)
$hash->{PortObj} = new Device::SerialPort($dev); $hash->{PortObj} = new Device::SerialPort($dev);
} }
if($hash->{PortObj}) { if($hash->{PortObj}) {
# Log 1, "Device $dev reopened";
Log3($name, 1, "Device $dev reopened"); Log3($name, 1, "Device $dev reopened");
$hash->{FD} = $hash->{PortObj}->FILENO if($^O !~ m/Win/); $hash->{FD} = $hash->{PortObj}->FILENO if($^O !~ m/Win/);
CM11_DoInit($hash->{NAME}, $hash->{ttytype}, $hash->{PortObj}); CM11_DoInit($hash->{NAME}, $hash->{ttytype}, $hash->{PortObj});
@ -193,7 +191,6 @@ CM11_Define($$)
$hash->{STATE} = "defined"; $hash->{STATE} = "defined";
if($dev eq "none") { if($dev eq "none") {
# Log 1, "CM11 device is none, commands will be echoed only";
Log3($name, 1, "CM11 device is none, commands will be echoed only"); Log3($name, 1, "CM11 device is none, commands will be echoed only");
$attr{$name}{dummy} = 1; $attr{$name}{dummy} = 1;
return undef; return undef;
@ -201,7 +198,6 @@ CM11_Define($$)
$hash->{DeviceName} = $dev; $hash->{DeviceName} = $dev;
$hash->{PARTIAL} = ""; $hash->{PARTIAL} = "";
# Log 3, "CM11 opening CM11 device $dev";
Log3($name, 3, "CM11 opening CM11 device $dev"); Log3($name, 3, "CM11 opening CM11 device $dev");
if ($^O=~/Win/) { if ($^O=~/Win/) {
require Win32::SerialPort; require Win32::SerialPort;
@ -212,13 +208,11 @@ CM11_Define($$)
} }
if(!$po) { if(!$po) {
my $msg = "Can't open $dev: $!"; my $msg = "Can't open $dev: $!";
# Log(3, $msg) if($hash->{MOBILE});
Log3($name, 3, $msg) if($hash->{MOBILE}); Log3($name, 3, $msg) if($hash->{MOBILE});
return $msg if(!$hash->{MOBILE}); return $msg if(!$hash->{MOBILE});
$readyfnlist{"$name.$dev"} = $hash; $readyfnlist{"$name.$dev"} = $hash;
return ""; return "";
} }
# Log 3, "CM11 opened CM11 device $dev";
Log3($name, 3, "CM11 opened CM11 device $dev"); Log3($name, 3, "CM11 opened CM11 device $dev");
$hash->{PortObj} = $po; $hash->{PortObj} = $po;
@ -249,7 +243,6 @@ CM11_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"); Log3($name, $lev, "deleting port for $d");
delete $defs{$d}{IODev}; delete $defs{$d}{IODev};
} }
@ -273,7 +266,6 @@ CM11_LogReadWrite($@)
{ {
my ($rw,$hash, $msg, $trlr) = @_; my ($rw,$hash, $msg, $trlr) = @_;
my $name= $hash->{NAME}; my $name= $hash->{NAME};
# Log GetLogLevel($name,5),
Log3($name, 5, "CM11 device " . $name . ": $rw " . Log3($name, 5, "CM11 device " . $name . ": $rw " .
sprintf("%2d: ", length($msg)) . unpack("H*", $msg)); sprintf("%2d: ", length($msg)) . unpack("H*", $msg));
} }
@ -323,13 +315,11 @@ CM11_ReadDirect($$)
$nfound = select($rin, undef, undef, $to); $nfound = select($rin, undef, undef, $to);
if($nfound < 0) { if($nfound < 0) {
next if ($! == EAGAIN() || $! == EINTR() || $! == 0); next if ($! == EAGAIN() || $! == EINTR() || $! == 0);
# Log GetLogLevel($name,3), "$prefix Select error $nfound / $!";
Log3($name, 3, "$prefix Select error $nfound / $!"); Log3($name, 3, "$prefix Select error $nfound / $!");
return undef; return undef;
} }
} }
if(!$nfound) { if(!$nfound) {
# Log GetLogLevel($name,3), "$prefix Timeout reading $arg";
Log3($name, 3, "$prefix Timeout reading $arg"); Log3($name, 3, "$prefix Timeout reading $arg");
return undef; return undef;
} }
@ -349,7 +339,6 @@ CM11_Write($$$)
my $prefix= "CM11 device $name:"; my $prefix= "CM11 device $name:";
if(!$hash || !defined($hash->{PortObj})) { if(!$hash || !defined($hash->{PortObj})) {
# Log GetLogLevel($name,3),
Log3($name, 3, "$prefix device is not active, cannot send"); Log3($name, 3, "$prefix device is not active, cannot send");
return; return;
@ -377,14 +366,11 @@ CM11_Write($$$)
my $checksum_r= unpack('C', $checksum); my $checksum_r= unpack('C', $checksum);
if($checksum_w ne $checksum_r) { if($checksum_w ne $checksum_r) {
# Log 5,
Log3($name, 5, "$prefix wrong checksum (send: $checksum_w, received: $checksum_r)"); Log3($name, 5, "$prefix wrong checksum (send: $checksum_w, received: $checksum_r)");
return 0 if(!$try); return 0 if(!$try);
my $nexttry= 6-$try; my $nexttry= 6-$try;
# Log 5,
Log3($name, 5, "$prefix retrying (" . $nexttry . "/5)"); Log3($name, 5, "$prefix retrying (" . $nexttry . "/5)");
} else { } else {
# Log 5, "$prefix checksum correct, OK for transmission";
Log3($name, 5, "$prefix checksum correct, OK for transmission"); Log3($name, 5, "$prefix checksum correct, OK for transmission");
last; last;
} }
@ -397,11 +383,9 @@ CM11_Write($$$)
my $ready= CM11_ReadDirect($hash, "ready"); my $ready= CM11_ReadDirect($hash, "ready");
return 0 if(!defined($ready)); # read failure return 0 if(!defined($ready)); # read failure
if($ready ne $msg_ifrdy) { if($ready ne $msg_ifrdy) {
# Log GetLogLevel($name,3),
Log3($name, 3, "$prefix strange ready signal (" . unpack('C', $ready) . ")"); Log3($name, 3, "$prefix strange ready signal (" . unpack('C', $ready) . ")");
return 0 return 0
} else { } else {
# Log 5, "$prefix ready";
Log3($name, 5, "$prefix ready"); Log3($name, 5, "$prefix ready");
} }
@ -438,17 +422,14 @@ sub CM11_Get($@)
my $v = join(" ", @a); my $v = join(" ", @a);
my $name = $hash->{NAME}; my $name = $hash->{NAME};
# Log GetLogLevel($name,2), "CM11 get $v";
Log3($name, 2, "CM11 get $v"); Log3($name, 2, "CM11 get $v");
my $statusmsg= CM11_GetInterfaceStatus($hash); my $statusmsg= CM11_GetInterfaceStatus($hash);
if(!defined($statusmsg)) { if(!defined($statusmsg)) {
$v= "error"; $v= "error";
# Log 2, "CM11 error, device is irresponsive."
Log3($name, 2, "CM11 error, device is irresponsive.") Log3($name, 2, "CM11 error, device is irresponsive.")
} else { } else {
my $msg= unpack("H*", $statusmsg); my $msg= unpack("H*", $statusmsg);
# Log 5, "CM11 got ". $msg;
Log3($name, 5, "CM11 got ". $msg); Log3($name, 5, "CM11 got ". $msg);
if($a[1] eq "fwrev") { if($a[1] eq "fwrev") {
@ -487,7 +468,6 @@ CM11_Set($@)
my $v = join(" ", @a); my $v = join(" ", @a);
my $name = $hash->{NAME}; my $name = $hash->{NAME};
# Log GetLogLevel($name,2), "CM11 set $v";
Log3($name, 2, "CM11 set $v"); Log3($name, 2, "CM11 set $v");
if($a[1] eq "reopen") { if($a[1] eq "reopen") {
@ -555,7 +535,6 @@ CM11_Read($)
# USB troubleshooting # USB troubleshooting
if(!defined($buf) || length($buf) == 0) { if(!defined($buf) || length($buf) == 0) {
my $dev = $hash->{DeviceName}; my $dev = $hash->{DeviceName};
# Log 1, "USB device $dev disconnected, waiting to reappear";
Log3($name, 1, "USB device $dev disconnected, waiting to reappear"); Log3($name, 1, "USB device $dev disconnected, waiting to reappear");
$hash->{PortObj}->close(); $hash->{PortObj}->close();
DoTrigger($name, "DISCONNECTED"); DoTrigger($name, "DISCONNECTED");
@ -577,7 +556,6 @@ CM11_Read($)
# concatenate yet unparsed message and newly received data # concatenate yet unparsed message and newly received data
my $x10data = $hash->{PARTIAL} . $buf; my $x10data = $hash->{PARTIAL} . $buf;
CM11_LogRead($hash,$buf); CM11_LogRead($hash,$buf);
# Log 5, "$prefix Data: " . unpack('H*',$x10data);
Log3($name, 5, "$prefix Data: " . unpack('H*',$x10data)); Log3($name, 5, "$prefix Data: " . unpack('H*',$x10data));
# normally the while loop will run only once # normally the while loop will run only once
@ -590,7 +568,6 @@ CM11_Read($)
# to start with, a single 0x5a is received # to start with, a single 0x5a is received
if( substr($x10data,0,1) eq $msg_pollpc ) { # CM11 polls PC if( substr($x10data,0,1) eq $msg_pollpc ) { # CM11 polls PC
# Log 5, "$prefix start of message";
Log3($name, 5, "$prefix start of message"); Log3($name, 5, "$prefix start of message");
CM11_SimpleWrite($hash, $msg_pollack); # PC ready CM11_SimpleWrite($hash, $msg_pollack); # PC ready
$x10data= substr($x10data,1); # $x10data now empty $x10data= substr($x10data,1); # $x10data now empty
@ -611,15 +588,12 @@ CM11_Read($)
# a single 0xa5 is a power-fail macro download poll # a single 0xa5 is a power-fail macro download poll
if( substr($x10data,0,1) eq $msg_pollpcpf ) { # CM11 polls PC if( substr($x10data,0,1) eq $msg_pollpcpf ) { # CM11 polls PC
# Log 5, "$prefix power-fail poll";
Log3($name, 5, "$prefix power-fail poll"); Log3($name, 5, "$prefix power-fail poll");
# the documentation wrongly says that the macros should be downloaded # the documentation wrongly says that the macros should be downloaded
# in fact, the time must be set! # in fact, the time must be set!
if(CM11_SetInterfaceTime($hash)) { if(CM11_SetInterfaceTime($hash)) {
# Log 5, "$prefix power-fail poll satisfied";
Log3($name, 5, "$prefix power-fail poll satisfied"); Log3($name, 5, "$prefix power-fail poll satisfied");
} else { } else {
# Log 5, "$prefix power-fail poll satisfaction failed";
Log3($name, 5, "$prefix power-fail poll satisfaction failed"); Log3($name, 5, "$prefix power-fail poll satisfaction failed");
} }
$x10data= substr($x10data,1); # $x10data now empty $x10data= substr($x10data,1); # $x10data now empty
@ -628,7 +602,6 @@ CM11_Read($)
# a single 0x55 is a leftover from a failed transmission # a single 0x55 is a leftover from a failed transmission
if( substr($x10data,0,1) eq $msg_ifrdy ) { # CM11 polls PC if( substr($x10data,0,1) eq $msg_ifrdy ) { # CM11 polls PC
# Log 5, "$prefix skipping leftover ready signal";
Log3($name, 5, "$prefix skipping leftover ready signal"); Log3($name, 5, "$prefix skipping leftover ready signal");
$x10data= substr($x10data,1); $x10data= substr($x10data,1);
next; next;
@ -648,7 +621,6 @@ CM11_Read($)
# $x10data now contains $len data bytes # $x10data now contains $len data bytes
my $databytes= unpack('H*', substr($x10data,0)); my $databytes= unpack('H*', substr($x10data,0));
# Log 5, "$prefix message complete " .
Log3($name, 5, "$prefix message complete " . Log3($name, 5, "$prefix message complete " .
"(length $len, mask $mask, data $databytes)"); "(length $len, mask $mask, data $databytes)");
@ -686,7 +658,6 @@ CM11_Read($)
unpack("H*", $command); unpack("H*", $command);
} }
$hash->{$housecode_func}= $x10func; $hash->{$housecode_func}= $x10func;
# Log 5, "$prefix $housecode_func: " .
Log3($name, 5, "$prefix $housecode_func: " . Log3($name, 5, "$prefix $housecode_func: " .
$hash->{$housecode_func}); $hash->{$housecode_func});
# dispatch message to clients # dispatch message to clients
@ -713,7 +684,6 @@ CM11_Read($)
$unitcodes= ""; $unitcodes= "";
} }
$hash->{$housecode_unit}= "$unitcodes$unitcode"; $hash->{$housecode_unit}= "$unitcodes$unitcode";
# Log 5, "$prefix $housecode_unit: " .
Log3($name, 5, "$prefix $housecode_unit: " . Log3($name, 5, "$prefix $housecode_unit: " .
$hash->{$housecode_unit}); $hash->{$housecode_unit});
} }
@ -745,7 +715,6 @@ CM11_Ready($$)
} }
return undef if(!$po); return undef if(!$po);
# Log 1, "USB device $dev reappeared";
Log3($name, 1, "USB device $dev reappeared"); Log3($name, 1, "USB device $dev reappeared");
$hash->{PortObj} = $po; $hash->{PortObj} = $po;
if( $^O !~ /Win/ ) { if( $^O !~ /Win/ ) {
@ -838,7 +807,6 @@ CM11_Ready($$)
<ul> <ul>
<li><a href="#do_not_notify">do_not_notify</a></li> <li><a href="#do_not_notify">do_not_notify</a></li>
<li><a href="#attrdummy">dummy</a></li> <li><a href="#attrdummy">dummy</a></li>
<li><a href="#loglevel">loglevel</a></li>
<li><a href="#model">model</a> (CM11)</li> <li><a href="#model">model</a> (CM11)</li>
</ul> </ul>
<br> <br>

View File

@ -19,7 +19,7 @@ HTTPSRV_addExtension($$$$) {
my ($name,$func,$link,$friendlyname)= @_; my ($name,$func,$link,$friendlyname)= @_;
my $url = "/$link"; my $url = "/$link";
Log 3, "Registering HTTPSRV $name for URL $url..."; Log3 $name, 3, "Registering HTTPSRV $name for URL $url...";
$data{FWEXT}{$url}{deviceName}= $name; $data{FWEXT}{$url}{deviceName}= $name;
$data{FWEXT}{$url}{FUNC} = $func; $data{FWEXT}{$url}{FUNC} = $func;
$data{FWEXT}{$url}{LINK} = $link; $data{FWEXT}{$url}{LINK} = $link;
@ -32,7 +32,7 @@ HTTPSRV_removeExtension($) {
my $url = "/$link"; my $url = "/$link";
my $name= $data{FWEXT}{$url}{deviceName}; my $name= $data{FWEXT}{$url}{deviceName};
Log 3, "Unregistering HTTPSRV $name for URL $url..."; Log3 $name, 3, "Unregistering HTTPSRV $name for URL $url...";
delete $data{FWEXT}{$url}; delete $data{FWEXT}{$url};
} }
@ -44,7 +44,7 @@ HTTPSRV_Initialize($) {
$hash->{DefFn} = "HTTPSRV_Define"; $hash->{DefFn} = "HTTPSRV_Define";
$hash->{UndefFn} = "HTTPSRV_Undef"; $hash->{UndefFn} = "HTTPSRV_Undef";
#$hash->{AttrFn} = "HTTPSRV_Attr"; #$hash->{AttrFn} = "HTTPSRV_Attr";
$hash->{AttrList} = "loglevel:0,1,2,3,4,5 directoryindex"; $hash->{AttrList} = "directoryindex";
#$hash->{SetFn} = "HTTPSRV_Set"; #$hash->{SetFn} = "HTTPSRV_Set";
return undef; return undef;

View File

@ -39,7 +39,7 @@ RSS_Initialize($) {
my ($hash) = @_; my ($hash) = @_;
$hash->{DefFn} = "RSS_Define"; $hash->{DefFn} = "RSS_Define";
#$hash->{AttrFn} = "RSS_Attr"; #$hash->{AttrFn} = "RSS_Attr";
$hash->{AttrList}= "loglevel:0,1,2,3,4,5 size bg tmin"; $hash->{AttrList}= "size bg tmin";
$hash->{SetFn} = "RSS_Set"; $hash->{SetFn} = "RSS_Set";
@ -281,7 +281,6 @@ RSS_itemImg {
my ($width,$height)= $I->getBounds(); my ($width,$height)= $I->getBounds();
my ($swidth,$sheight)= (int($scale*$width), int($scale*$height)); my ($swidth,$sheight)= (int($scale*$width), int($scale*$height));
#Debug "RSS placing $arg ($swidth x $sheight) at ($x,$y)"; #Debug "RSS placing $arg ($swidth x $sheight) at ($x,$y)";
Log 5, "RSS placing $arg ($swidth x $sheight) at ($x,$y)";
$S->copyResampled($I,$x,$y,0,0,$swidth,$sheight,$width,$height); $S->copyResampled($I,$x,$y,0,0,$swidth,$sheight,$width,$height);
} }
@ -318,10 +317,10 @@ RSS_evalLayout($$@) {
if($line=~ s/\\$//) { $cont= $line; undef $line; } if($line=~ s/\\$//) { $cont= $line; undef $line; }
next unless($line); next unless($line);
$cont= ""; $cont= "";
#Log 5, "$name: evaluating >$line<"; #Debug "$name: evaluating >$line<";
# split line into command and definition # split line into command and definition
my ($cmd, $def)= split("[ \t]+", $line, 2); my ($cmd, $def)= split("[ \t]+", $line, 2);
#Log 5, "CMD= \"$cmd\", DEF= \"$def\""; ##Debug, "CMD= \"$cmd\", DEF= \"$def\"";
if($cmd eq "rgb") { if($cmd eq "rgb") {
$def= "\"$def\"" if(length($def) == 6 && $def =~ /[[:xdigit:]]{6}/); $def= "\"$def\"" if(length($def) == 6 && $def =~ /[[:xdigit:]]{6}/);
$params{rgb}= AnalyzePerlCommand(undef, $def); $params{rgb}= AnalyzePerlCommand(undef, $def);
@ -332,7 +331,7 @@ RSS_evalLayout($$@) {
} elsif($cmd eq "text") { } elsif($cmd eq "text") {
($x,$y,$text)= split("[ \t]+", $def, 3); ($x,$y,$text)= split("[ \t]+", $def, 3);
my $txt= AnalyzePerlCommand(undef, $text); my $txt= AnalyzePerlCommand(undef, $text);
#Log 5, "$name: ($x,$y) $txt"; #Debug "$name: ($x,$y) $txt";
RSS_itemText($S,$x,$y,$txt,%params); RSS_itemText($S,$x,$y,$txt,%params);
} elsif($cmd eq "line") { } elsif($cmd eq "line") {
($x1,$y1,$x2,$y2)= split("[ \t]+", $def, 4); ($x1,$y1,$x2,$y2)= split("[ \t]+", $def, 4);
@ -351,7 +350,7 @@ RSS_evalLayout($$@) {
my $arg= AnalyzePerlCommand(undef, $arg); my $arg= AnalyzePerlCommand(undef, $arg);
RSS_itemImg($S,$x,$y,$scale,$imgtype,$srctype,$arg,%params); RSS_itemImg($S,$x,$y,$scale,$imgtype,$srctype,$arg,%params);
} else { } else {
Log 1, "$name: Illegal command $cmd in layout definition."; Log3 $name, 1, "$name: Illegal command $cmd in layout definition.";
} }
} }

View File

@ -22,7 +22,7 @@ BS_Initialize($)
$hash->{UndefFn} = "BS_Undef"; $hash->{UndefFn} = "BS_Undef";
$hash->{ParseFn} = "BS_Parse"; $hash->{ParseFn} = "BS_Parse";
$hash->{AttrList} = "do_not_notify:1,0 showtime:0,1 ". $hash->{AttrList} = "do_not_notify:1,0 showtime:0,1 ".
"ignore:1,0 model:BS loglevel:0,1,2,3,4,5,6 " . $readingFnAttributes; "ignore:1,0 model:BS " . $readingFnAttributes;
} }
@ -85,7 +85,7 @@ BS_Parse($$)
my $def= $modules{BS}{defptr}{$dev}; my $def= $modules{BS}{defptr}{$dev};
if(!defined($def)) { if(!defined($def)) {
$sensor =~ s/^0//; $sensor =~ s/^0//;
Log 3, "BS Unknown device $sensor, please define it"; Log3 $hash, 3, "BS Unknown device $sensor, please define it";
return "UNDEFINED BS_$sensor BS $sensor"; return "UNDEFINED BS_$sensor BS $sensor";
} }
@ -112,7 +112,7 @@ BS_Parse($$)
readingsBeginUpdate($def); readingsBeginUpdate($def);
readingsBulkUpdate($def, "state", $state); readingsBulkUpdate($def, "state", $state);
#Log GetLogLevel($name, 4), "BS $name: $state"; #Debug "BS $name: $state";
readingsBulkUpdate($def, "brightness", $brightness); readingsBulkUpdate($def, "brightness", $brightness);
readingsBulkUpdate($def, "lux", $lux); readingsBulkUpdate($def, "lux", $lux);
readingsBulkUpdate($def, "flags", $flags); readingsBulkUpdate($def, "flags", $flags);
@ -186,7 +186,6 @@ BS_Parse($$)
<ul> <ul>
<li><a href="#do_not_notify">do_not_notify</a></li> <li><a href="#do_not_notify">do_not_notify</a></li>
<li><a href="#showtime">showtime</a></li> <li><a href="#showtime">showtime</a></li>
<li><a href="#loglevel">loglevel</a></li>
<li><a href="#model">model</a> (bs)</li> <li><a href="#model">model</a> (bs)</li>
<li><a href="#ignore">ignore</a></li> <li><a href="#ignore">ignore</a></li>
<li><a href="#readingFnAttributes">readingFnAttributes</a></li> <li><a href="#readingFnAttributes">readingFnAttributes</a></li>

View File

@ -26,7 +26,7 @@ USF1000_Initialize($)
$hash->{UndefFn} = "USF1000_Undef"; $hash->{UndefFn} = "USF1000_Undef";
$hash->{ParseFn} = "USF1000_Parse"; $hash->{ParseFn} = "USF1000_Parse";
$hash->{AttrList} = "IODev do_not_notify:1,0 ignore:0,1 showtime:0,1 " . $hash->{AttrList} = "IODev do_not_notify:1,0 ignore:0,1 showtime:0,1 " .
"model:usf1000s loglevel:0,1,2,3,4,5,6 " . $readingFnAttributes; "model:usf1000s " . $readingFnAttributes;
} }
@ -92,7 +92,7 @@ USF1000_Parse($$)
my ($hash, $msg) = @_; # hash points to the FHZ, not to the USF1000 my ($hash, $msg) = @_; # hash points to the FHZ, not to the USF1000
if(!defined($modules{USF1000}{defptr}{$dev})) { if(!defined($modules{USF1000}{defptr}{$dev})) {
Log 3, "USF1000 Unknown device, please define it"; Log3 $hash, 3, "USF1000 Unknown device, please define it";
return "UNDEFINED USF1000 USF1000 cylv 1 1 0.5"; return "UNDEFINED USF1000 USF1000 cylv 1 1 0.5";
} }
@ -150,7 +150,6 @@ USF1000_Parse($$)
readingsBulkUpdate($def, "level", $flevel); readingsBulkUpdate($def, "level", $flevel);
readingsBulkUpdate($def, "volume", $volume); readingsBulkUpdate($def, "volume", $volume);
#Log GetLogLevel($name, 4), "USF1000 $name: $state";
#Debug "USF1000 $name: $state"; #Debug "USF1000 $name: $state";
} }
@ -241,7 +240,6 @@ USF1000_Parse($$)
<li><a href="#IODev">IODev</a></li><br> <li><a href="#IODev">IODev</a></li><br>
<li><a href="#do_not_notify">do_not_notify</a></li> <li><a href="#do_not_notify">do_not_notify</a></li>
<li><a href="#showtime">showtime</a></li> <li><a href="#showtime">showtime</a></li>
<li><a href="#loglevel">loglevel</a></li>
<li><a href="#model">model</a> (usf1000s)</li> <li><a href="#model">model</a> (usf1000s)</li>
<li><a href="#ignore">ignore</a></li> <li><a href="#ignore">ignore</a></li>
<li><a href="#readingFnAttributes">readingFnAttributes</a></li> <li><a href="#readingFnAttributes">readingFnAttributes</a></li>

View File

@ -111,7 +111,7 @@ OWServer_Initialize($)
$hash->{GetFn} = "OWServer_Get"; $hash->{GetFn} = "OWServer_Get";
$hash->{SetFn} = "OWServer_Set"; $hash->{SetFn} = "OWServer_Set";
# $hash->{AttrFn} = "OWServer_Attr"; # $hash->{AttrFn} = "OWServer_Attr";
$hash->{AttrList}= "nonblocking loglevel:0,1,2,3,4,5"; $hash->{AttrList}= "nonblocking " . $readingFnAttributes;
} }
##################################### #####################################
@ -152,7 +152,7 @@ OWServer_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 OWServer for $d"; Log3 $name, $lev, "deleting OWServer for $d";
delete $defs{$d}{IODev}; delete $defs{$d}{IODev};
} }
} }
@ -182,10 +182,10 @@ OWServer_OpenDev($)
OWServer_CloseDev($hash); OWServer_CloseDev($hash);
my $protocol= $hash->{fhem}{protocol}; my $protocol= $hash->{fhem}{protocol};
Log 3, "$name: Opening connection to OWServer $protocol..."; Log3 $name, 3, "$name: Opening connection to OWServer $protocol...";
my $owserver= OWNet->new($protocol); my $owserver= OWNet->new($protocol);
if($owserver) { if($owserver) {
Log 3, "$name: Successfully connected to $protocol."; Log3 $name, 3, "$name: Successfully connected to $protocol.";
$hash->{fhem}{owserver}= $owserver; $hash->{fhem}{owserver}= $owserver;
readingsSingleUpdate($hash, "state", "CONNECTED", 1); readingsSingleUpdate($hash, "state", "CONNECTED", 1);
my $ret = OWServer_DoInit($hash); my $ret = OWServer_DoInit($hash);
@ -249,7 +249,7 @@ OWServer_Read($@)
my $pid= fork; my $pid= fork;
if(!defined($pid)) { if(!defined($pid)) {
Log 1, "OWServer: Cannot fork: $!"; Log3 $hash, 1, "OWServer: Cannot fork: $!";
return undef; return undef;
} }
@ -258,14 +258,14 @@ OWServer_Read($@)
close READER; close READER;
$ret= OWNet::read($hash->{DEF},$path); $ret= OWNet::read($hash->{DEF},$path);
$ret =~ s/^\s+//g if(defined($ret)); $ret =~ s/^\s+//g if(defined($ret));
Log 5, "OWServer child read $path: $ret"; Log3 $hash, 5, "OWServer child read $path: $ret";
delete $hash->{".path"}; delete $hash->{".path"};
print WRITER $ret; print WRITER $ret;
close WRITER; close WRITER;
exit 0; exit 0;
} }
Log 5, "OWServer child ID for reading '$path' is $pid"; Log3 $hash, 5, "OWServer child ID for reading '$path' is $pid";
close WRITER; close WRITER;
chomp($ret= <READER>); chomp($ret= <READER>);
close READER; close READER;
@ -286,7 +286,7 @@ sub
OWServer_TimeoutChild($) OWServer_TimeoutChild($)
{ {
my $pid= shift; my $pid= shift;
Log 1, "OWServer: Terminated child $pid" if($pid && kill(9, $pid)); Log3 undef, 1, "OWServer: Terminated child $pid" if($pid && kill(9, $pid));
} }
##################################### #####################################
@ -360,20 +360,20 @@ OWServer_Autocreate($)
my $address= substr($device,1); my $address= substr($device,1);
my $family= substr($address,0,2); my $family= substr($address,0,2);
if(!exists $owfamily{$family}) { if(!exists $owfamily{$family}) {
Log 2, "$name: Autocreate: unknown familycode '$family' found. Please report this!"; Log3 $name, 2, "$name: Autocreate: unknown familycode '$family' found. Please report this!";
next; next;
} else { } else {
my $type= $owserver->read($device . "/type"); my $type= $owserver->read($device . "/type");
my $owtype= $owfamily{$family}; my $owtype= $owfamily{$family};
if($owtype !~ m/$type/) { if($owtype !~ m/$type/) {
Log 2, "$name: Autocreate: type '$type' not defined in familycode '$family'. Please report this!"; Log3 $name, 2, "$name: Autocreate: type '$type' not defined in familycode '$family'. Please report this!";
next; next;
} else { } else {
foreach my $d (keys %defs) { foreach my $d (keys %defs) {
next if($defs{$d}{TYPE} ne "OWDevice"); next if($defs{$d}{TYPE} ne "OWDevice");
if(defined($defs{$d}{fhem}) && if(defined($defs{$d}{fhem}) &&
defined($defs{$d}{fhem}{address}) && $defs{$d}{fhem}{address} eq $address) { defined($defs{$d}{fhem}{address}) && $defs{$d}{fhem}{address} eq $address) {
Log 5, "$name address '$address' already defined as '$defs{$d}{NAME}'"; Log3 $name, 5, "$name address '$address' already defined as '$defs{$d}{NAME}'";
next; next;
} else { } else {
my $id= substr($address,3); my $id= substr($address,3);
@ -381,13 +381,13 @@ OWServer_Autocreate($)
if(defined($defs{$devname}) || grep {$_ eq $address} @defined) { if(defined($defs{$devname}) || grep {$_ eq $address} @defined) {
next; next;
} else { } else {
Log 5, "$name create new device '$devname' for address '$address'"; Log3 $name, 5, "$name create new device '$devname' for address '$address'";
my $interval= ($family eq "81") ? "" : " 60"; my $interval= ($family eq "81") ? "" : " 60";
my $define= "$devname OWDevice $address" . $interval; my $define= "$devname OWDevice $address" . $interval;
my $cmdret; my $cmdret;
$cmdret= CommandDefine(undef,$define); $cmdret= CommandDefine(undef,$define);
if($cmdret) { if($cmdret) {
Log 1, "$name: Autocreate: An error occurred while creating device for address '$address': $cmdret"; Log3 $name, 1, "$name: Autocreate: An error occurred while creating device for address '$address': $cmdret";
} else { } else {
$cmdret= CommandAttr(undef,"$devname room OWDevice"); $cmdret= CommandAttr(undef,"$devname room OWDevice");
} }
@ -607,7 +607,6 @@ OWServer_Set($@)
Example:<br> Example:<br>
<code> attr &lt;name&gt; nonblocking 1</code> <code> attr &lt;name&gt; nonblocking 1</code>
</li> </li>
<li><a href="#loglevel">loglevel</a></li>
<li><a href="#eventMap">eventMap</a></li> <li><a href="#eventMap">eventMap</a></li>
<li><a href="#readingFnAttributes">readingFnAttributes</a></li> <li><a href="#readingFnAttributes">readingFnAttributes</a></li>
</ul> </ul>

View File

@ -352,7 +352,7 @@ OWDevice_Initialize($)
$hash->{UndefFn} = "OWDevice_Undef"; $hash->{UndefFn} = "OWDevice_Undef";
$hash->{AttrFn} = "OWDevice_Attr"; $hash->{AttrFn} = "OWDevice_Attr";
$hash->{AttrList} = "IODev uncached trimvalues polls interfaces model loglevel:0,1,2,3,4,5 ". $hash->{AttrList} = "IODev uncached trimvalues polls interfaces model ".
$readingFnAttributes; $readingFnAttributes;
} }
@ -397,7 +397,7 @@ OWDevice_ReadFromServer($$@)
!$iohash->{TYPE} || !$iohash->{TYPE} ||
!$modules{$iohash->{TYPE}} || !$modules{$iohash->{TYPE}} ||
!$modules{$iohash->{TYPE}}{ReadFn}) { !$modules{$iohash->{TYPE}}{ReadFn}) {
Log 5, "No I/O device or ReadFn found for $dev"; Log3 $hash, 5, "No I/O device or ReadFn found for $dev";
return; return;
} }
@ -431,7 +431,7 @@ OWDevice_ReadValue($$) {
if(defined($value)) { if(defined($value)) {
$value= trim($value) if(AttrVal($hash,"trimvalues",1)); $value= trim($value) if(AttrVal($hash,"trimvalues",1));
} else { } else {
Log 3, $hash->{NAME} . ": reading $reading did not return a value"; Log3 $hash, 3, $hash->{NAME} . ": reading $reading did not return a value";
} }
} }
@ -517,14 +517,14 @@ OWDevice_Attr($@)
if($attrName eq "polls") { if($attrName eq "polls") {
my @polls= split(",", $attrVal); my @polls= split(",", $attrVal);
$hash->{fhem}{polls}= \@polls; $hash->{fhem}{polls}= \@polls;
Log 5, "$name: polls: " . join(" ", @polls); Log3 $name, 5, "$name: polls: " . join(" ", @polls);
} elsif($attrName eq "interfaces") { } elsif($attrName eq "interfaces") {
if($attrVal ne "") { if($attrVal ne "") {
$hash->{fhem}{interfaces}= join(";",split(",",$attrVal)); $hash->{fhem}{interfaces}= join(";",split(",",$attrVal));
Log 5, "$name: interfaces: " . $hash->{fhem}{interfaces}; Log3 $name, 5, "$name: interfaces: " . $hash->{fhem}{interfaces};
} else { } else {
delete $hash->{fhem}{interfaces} if(defined($hash->{fhem}{interfaces})); delete $hash->{fhem}{interfaces} if(defined($hash->{fhem}{interfaces}));
Log 5, "$name: no interfaces"; Log3 $name, 5, "$name: no interfaces";
} }
} }
} }
@ -613,15 +613,15 @@ OWDevice_Define($$)
AssignIoPort($hash) if(!defined($hash->{IODev}->{NAME})); AssignIoPort($hash) if(!defined($hash->{IODev}->{NAME}));
if(defined($hash->{IODev}->{NAME})) { if(defined($hash->{IODev}->{NAME})) {
Log 4, "$name: I/O device is " . $hash->{IODev}->{NAME}; Log3 $name, 4, "$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";
} }
$hash->{fhem}{address}= $a[2]; $hash->{fhem}{address}= $a[2];
if($#a == 3) { if($#a == 3) {
$hash->{fhem}{interval}= $a[3]; $hash->{fhem}{interval}= $a[3];
Log 5, "$name: polling every $a[3] seconds"; Log3 $name, 5, "$name: polling every $a[3] seconds";
} }
my ($interface, $gettersref, $settersref, $pollsref, $stateref, $alerting)= OWDevice_GetDetails($hash); my ($interface, $gettersref, $settersref, $pollsref, $stateref, $alerting)= OWDevice_GetDetails($hash);
my @getters= @{$gettersref}; my @getters= @{$gettersref};
@ -630,18 +630,18 @@ OWDevice_Define($$)
my @state= @{$stateref}; my @state= @{$stateref};
if($interface ne "") { if($interface ne "") {
$hash->{fhem}{interfaces}= $interface; $hash->{fhem}{interfaces}= $interface;
Log 5, "$name: interfaces: $interface"; Log3 $name, 5, "$name: interfaces: $interface";
} }
$hash->{fhem}{getters}= $gettersref; $hash->{fhem}{getters}= $gettersref;
Log 5, "$name: getters: " . join(" ", @getters); Log3 $name, 5, "$name: getters: " . join(" ", @getters);
$hash->{fhem}{setters}= $settersref; $hash->{fhem}{setters}= $settersref;
Log 5, "$name: setters: " . join(" ", @setters); Log3 $name, 5, "$name: setters: " . join(" ", @setters);
$hash->{fhem}{polls}= $pollsref; $hash->{fhem}{polls}= $pollsref;
Log 5, "$name: polls: " . join(" ", @polls); Log3 $name, 5, "$name: polls: " . join(" ", @polls);
$hash->{fhem}{state}= $stateref; $hash->{fhem}{state}= $stateref;
Log 5, "$name: state: " . join(" ", @state); Log3 $name, 5, "$name: state: " . join(" ", @state);
$hash->{fhem}{alerting}= $alerting; $hash->{fhem}{alerting}= $alerting;
Log 5, "$name: alerting: $alerting"; Log3 $name, 5, "$name: alerting: $alerting";
$hash->{fhem}{bus}= OWDevice_ReadFromServer($hash,"find",$hash->{fhem}{address}); $hash->{fhem}{bus}= OWDevice_ReadFromServer($hash,"find",$hash->{fhem}{address});
$attr{$name}{model}= OWDevice_ReadValue($hash, "type"); $attr{$name}{model}= OWDevice_ReadValue($hash, "type");
@ -810,7 +810,6 @@ OWDevice_Define($$)
<li>polls: a comma-separated list of readings to poll. This supersedes the list of default readings to poll.</li> <li>polls: a comma-separated list of readings to poll. This supersedes the list of default readings to poll.</li>
<li>interfaces: supersedes the interfaces exposed by that device.</li> <li>interfaces: supersedes the interfaces exposed by that device.</li>
<li>model: preset with device type, e.g. DS18S20.</li> <li>model: preset with device type, e.g. DS18S20.</li>
<li><a href="#loglevel">loglevel</a></li>
<li><a href="#eventMap">eventMap</a></li> <li><a href="#eventMap">eventMap</a></li>
<li><a href="#readingFnAttributes">readingFnAttributes</a></li> <li><a href="#readingFnAttributes">readingFnAttributes</a></li>
</ul> </ul>

View File

@ -132,8 +132,7 @@ X10_Initialize($)
$hash->{UndefFn} = "X10_Undef"; $hash->{UndefFn} = "X10_Undef";
$hash->{ParseFn} = "X10_Parse"; $hash->{ParseFn} = "X10_Parse";
$hash->{AttrList} = "IODev do_not_notify:1,0 " . $hash->{AttrList} = "IODev do_not_notify:1,0 " .
"dummy:1,0 showtime:1,0 model:lm12,lm15,am12,tm13 " . "dummy:1,0 showtime:1,0 model:lm12,lm15,am12,tm13";
"loglevel:0,1,2,3,4,5,6";
} }
@ -174,7 +173,7 @@ X10_StateMachine($$$$)
$bright= $hash->{BRIGHT}; $bright= $hash->{BRIGHT};
} else { } else {
$bright= 0; } $bright= 0; }
#Log 1, $hash->{NAME} . " initial state ($onoff,$bright)"; #Log3 $hash, 1, $hash->{NAME} . " initial state ($onoff,$bright)";
if($onoff) { if($onoff) {
# initial state (on,bright) # initial state (on,bright)
@ -202,7 +201,7 @@ X10_StateMachine($$$$)
if($bright< 0) { $bright= 0 }; if($bright< 0) { $bright= 0 };
} }
} }
#Log 1, $hash->{NAME} . " final state ($onoff,$bright)"; #Log3 $hash, 1, $hash->{NAME} . " final state ($onoff,$bright)";
$hash->{ONOFF}= $onoff; $hash->{ONOFF}= $onoff;
$hash->{BRIGHT}= $bright; $hash->{BRIGHT}= $bright;
@ -237,7 +236,7 @@ X10_Do_On_Till($@)
my $hms_till = sprintf("%02d:%02d:%02d", $hr, $min, $sec); my $hms_till = sprintf("%02d:%02d:%02d", $hr, $min, $sec);
my $hms_now = sprintf("%02d:%02d:%02d", $lt[2], $lt[1], $lt[0]); my $hms_now = sprintf("%02d:%02d:%02d", $lt[2], $lt[1], $lt[0]);
if($hms_now ge $hms_till) { if($hms_now ge $hms_till) {
Log 4, "on-till: won't switch as now ($hms_now) is later than $hms_till"; Log3 $hash, 4, "on-till: won't switch as now ($hms_now) is later than $hms_till";
return ""; return "";
} }
@ -289,7 +288,7 @@ X11_Write($$$)
undef $function; # do not use after this point undef $function; # do not use after this point
my $prefix= "X10 device $name:"; my $prefix= "X10 device $name:";
Log 5, "$prefix sending X10:$housecode;$unitcode;$x10func $dim"; Log3 $name, 5, "$prefix sending X10:$housecode;$unitcode;$x10func $dim";
my ($hc_b, $hu_b, $hf_b); my ($hc_b, $hu_b, $hf_b);
my ($hc, $hu, $hf); my ($hc, $hu, $hf);
@ -371,7 +370,7 @@ X10_Set($@)
X11_Write($hash, $function, $dim) if(!IsDummy($a[0])); X11_Write($hash, $function, $dim) if(!IsDummy($a[0]));
my $v = join(" ", @a); my $v = join(" ", @a);
Log GetLogLevel($a[0],2), "X10 set $v"; Log3 $a[0], 2, "X10 set $v";
(undef, $v) = split(" ", $v, 2); # Not interested in the name... (undef, $v) = split(" ", $v, 2); # Not interested in the name...
my $tn = TimeNow(); my $tn = TimeNow();
@ -475,7 +474,7 @@ X10_Parse($$)
} }
# no units for that housecode # no units for that housecode
if($unitcodes eq "") { if($unitcodes eq "") {
Log 3, "X10 No units with housecode $housecode, command $command, " . Log3 $hash, 3, "X10 No units with housecode $housecode, command $command, " .
"please define one"; "please define one";
push(@list, push(@list,
"UNDEFINED X10_$housecode X10 lm15 $housecode ?"); "UNDEFINED X10_$housecode X10 lm15 $housecode ?");
@ -489,7 +488,7 @@ X10_Parse($$)
if(!int(@unitcodes)) { if(!int(@unitcodes)) {
# command without unitcodes, this happens when a single on/off is sent # command without unitcodes, this happens when a single on/off is sent
# but no unit was previously selected # but no unit was previously selected
Log 3, "X10 No unit selected for housecode $housecode, command $command"; Log3 $hash, 3, "X10 No unit selected for housecode $housecode, command $command";
push(@list, push(@list,
"UNDEFINED X10_$housecode X10 lm15 $housecode ?"); "UNDEFINED X10_$housecode X10 lm15 $housecode ?");
return @list; return @list;
@ -517,10 +516,10 @@ X10_Parse($$)
$h->{READINGS}{state}{TIME} = $tn; $h->{READINGS}{state}{TIME} = $tn;
$h->{READINGS}{state}{VAL} = $value; $h->{READINGS}{state}{VAL} = $value;
X10_StateMachine($h, $tn, $function, $arg); X10_StateMachine($h, $tn, $function, $arg);
Log GetLogLevel($name,2), "X10 $name $value"; Log3 $hash, 2, "X10 $name $value";
push(@list, $name); push(@list, $name);
} else { } else {
Log 3, "X10 Unknown device $housecode $unitcode, command $command, " . Log3 $hash, 3, "X10 Unknown device $housecode $unitcode, command $command, " .
"please define it"; "please define it";
push(@list, push(@list,
"UNDEFINED X10_$housecode X10 lm15 $housecode $unitcode"); "UNDEFINED X10_$housecode X10 lm15 $housecode $unitcode");
@ -643,7 +642,6 @@ X10_Parse($$)
<li><a href="#attrdummy">dummy</a></li> <li><a href="#attrdummy">dummy</a></li>
<li><a href="#showtime">showtime</a></li> <li><a href="#showtime">showtime</a></li>
<li><a href="#model">model</a> (lm12,lm15,am12,tm13)</li> <li><a href="#model">model</a> (lm12,lm15,am12,tm13)</li>
<li><a href="#loglevel">loglevel</a></li>
<li><a href="#IODev">IODev</a></li><br> <li><a href="#IODev">IODev</a></li><br>
<li><a href="#eventMap">eventMap</a></li><br> <li><a href="#eventMap">eventMap</a></li><br>
</ul> </ul>

View File

@ -31,11 +31,6 @@ use HttpUtils;
package main; package main;
sub debug($) {
my ($msg)= @_;
Log 1, "DEBUG: " . $msg;
}
##################################### #####################################
# #
@ -53,18 +48,18 @@ sub new {
bless $self, $class; bless $self, $class;
$self->{type}= $type; $self->{type}= $type;
$self->{entries}= []; $self->{entries}= [];
#main::debug "NEW: $type"; #main::Debug "NEW: $type";
return($self); return($self);
} }
sub addproperty { sub addproperty {
my ($self,$line)= @_; my ($self,$line)= @_;
# TRIGGER;VALUE=DATE-TIME:20120531T150000Z # TRIGGER;VALUE=DATE-TIME:20120531T150000Z
#main::debug "line= $line"; #main::Debug "line= $line";
my ($property,$parameter)= split(":", $line,2); # TRIGGER;VALUE=DATE-TIME 20120531T150000Z my ($property,$parameter)= split(":", $line,2); # TRIGGER;VALUE=DATE-TIME 20120531T150000Z
#main::debug "property= $property parameter= $parameter"; #main::Debug "property= $property parameter= $parameter";
my ($key,$parts)= split(";", $property,2); my ($key,$parts)= split(";", $property,2);
#main::debug "key= $key parts= $parts"; #main::Debug "key= $key parts= $parts";
$parts= "" unless(defined($parts)); $parts= "" unless(defined($parts));
$parameter= "" unless(defined($parameter)); $parameter= "" unless(defined($parameter));
if($key eq "EXDATE") { if($key eq "EXDATE") {
@ -74,8 +69,8 @@ sub addproperty {
PARTS => "$parts", PARTS => "$parts",
VALUE => "$parameter" VALUE => "$parameter"
}; };
#main::debug "ADDPROPERTY: ". $self ." key= $key, parts= $parts, value= $parameter"; #main::Debug "ADDPROPERTY: ". $self ." key= $key, parts= $parts, value= $parameter";
#main::debug "WE ARE " . $self->{properties}{$key}{VALUE}; #main::Debug "WE ARE " . $self->{properties}{$key}{VALUE};
} }
sub value { sub value {
@ -95,12 +90,12 @@ sub parse {
sub parseSub { sub parseSub {
my ($self,$ln,@ical)= @_; my ($self,$ln,@ical)= @_;
#main::debug "ENTER @ $ln"; #main::Debug "ENTER @ $ln";
while($ln<$#ical) { while($ln<$#ical) {
my $line= $ical[$ln]; my $line= $ical[$ln];
chomp $line; chomp $line;
$line =~ s/[\x0D]//; # chomp will not remove the CR $line =~ s/[\x0D]//; # chomp will not remove the CR
#main::debug "$ln: $line"; #main::Debug "$ln: $line";
$ln++; $ln++;
last if($line =~ m/^END:.*$/); last if($line =~ m/^END:.*$/);
if($line =~ m/^BEGIN:(.*)$/) { if($line =~ m/^BEGIN:(.*)$/) {
@ -111,7 +106,7 @@ sub parseSub {
$self->addproperty($line); $self->addproperty($line);
} }
} }
#main::debug "BACK"; #main::Debug "BACK";
return $ln; return $ln;
} }
@ -165,10 +160,10 @@ sub start {
sub setState { sub setState {
my ($self,$state)= @_; my ($self,$state)= @_;
#main::debug "Before setState $state: States(" . $self->uid() . ") " . $self->{_previousState} . " -> " . $self->{_state}; #main::Debug "Before setState $state: States(" . $self->uid() . ") " . $self->{_previousState} . " -> " . $self->{_state};
$self->{_previousState}= $self->{_state}; $self->{_previousState}= $self->{_state};
$self->{_state}= $state; $self->{_state}= $state;
#main::debug "After setState $state: States(" . $self->uid() . ") " . $self->{_previousState} . " -> " . $self->{_state}; #main::Debug "After setState $state: States(" . $self->uid() . ") " . $self->{_previousState} . " -> " . $self->{_state};
return $state; return $state;
} }
@ -176,7 +171,7 @@ sub setMode {
my ($self,$mode)= @_; my ($self,$mode)= @_;
$self->{_previousMode}= $self->{_mode}; $self->{_previousMode}= $self->{_mode};
$self->{_mode}= $mode; $self->{_mode}= $mode;
#main::debug "After setMode $mode: Modes(" . $self->uid() . ") " . $self->{_previousMode} . " -> " . $self->{_mode}; #main::Debug "After setMode $mode: Modes(" . $self->uid() . ") " . $self->{_previousMode} . " -> " . $self->{_mode};
return $mode; return $mode;
} }
@ -234,7 +229,7 @@ sub isDeleted {
sub stateChanged { sub stateChanged {
my ($self)= @_; my ($self)= @_;
#main::debug "States(" . $self->uid() . ") " . $self->{_previousState} . " -> " . $self->{_state}; #main::Debug "States(" . $self->uid() . ") " . $self->{_previousState} . " -> " . $self->{_state};
return $self->{_state} ne $self->{_previousState} ? 1 : 0; return $self->{_state} ne $self->{_previousState} ? 1 : 0;
} }
@ -250,20 +245,20 @@ sub modeChanged {
sub tm { sub tm {
my ($t)= @_; my ($t)= @_;
return undef if(!$t); return undef if(!$t);
#main::debug "convert >$t<"; #main::Debug "convert >$t<";
my ($year,$month,$day)= (substr($t,0,4), substr($t,4,2),substr($t,6,2)); my ($year,$month,$day)= (substr($t,0,4), substr($t,4,2),substr($t,6,2));
if(length($t)>8) { if(length($t)>8) {
my ($hour,$minute,$second)= (substr($t,9,2), substr($t,11,2),substr($t,13,2)); my ($hour,$minute,$second)= (substr($t,9,2), substr($t,11,2),substr($t,13,2));
my $z; my $z;
$z= substr($t,15,1) if(length($t) == 16); $z= substr($t,15,1) if(length($t) == 16);
#main::debug "$day.$month.$year $hour:$minute:$second $z"; #main::Debug "$day.$month.$year $hour:$minute:$second $z";
if($z) { if($z) {
return main::fhemTimeGm($second,$minute,$hour,$day,$month-1,$year-1900); return main::fhemTimeGm($second,$minute,$hour,$day,$month-1,$year-1900);
} else { } else {
return main::fhemTimeLocal($second,$minute,$hour,$day,$month-1,$year-1900); return main::fhemTimeLocal($second,$minute,$hour,$day,$month-1,$year-1900);
} }
} else { } else {
#main::debug "$day.$month.$year"; #main::Debug "$day.$month.$year";
return main::fhemTimeLocal(0,0,0,$day,$month-1,$year-1900); return main::fhemTimeLocal(0,0,0,$day,$month-1,$year-1900);
} }
} }
@ -283,7 +278,7 @@ sub tm {
sub d { sub d {
my ($d)= @_; my ($d)= @_;
#main::debug "Duration $d"; #main::Debug "Duration $d";
my $sign= 1; my $sign= 1;
my $t= 0; my $t= 0;
@ -301,13 +296,13 @@ sub d {
$t+= $1*3600+$2*60+$3; $t+= $1*3600+$2*60+$3;
} }
$t*= $sign; $t*= $sign;
#main::debug "sign: $sign dw: $dw dt: $dt t= $t"; #main::Debug "sign: $sign dw: $dw dt: $dt t= $t";
return $t; return $t;
} }
sub dt { sub dt {
my ($t0,$value,$parts)= @_; my ($t0,$value,$parts)= @_;
#main::debug "t0= $t0 parts= $parts value= $value"; #main::Debug "t0= $t0 parts= $parts value= $value";
if(defined($parts) && $parts =~ m/VALUE=DATE/) { if(defined($parts) && $parts =~ m/VALUE=DATE/) {
return tm($value); return tm($value);
} else { } else {
@ -332,11 +327,11 @@ sub ts0 {
sub plusNMonths($$) { sub plusNMonths($$) {
my ($tm, $n)= @_; my ($tm, $n)= @_;
my ($second,$minute,$hour,$day,$month,$year,$wday,$yday,$isdst)= localtime($tm); my ($second,$minute,$hour,$day,$month,$year,$wday,$yday,$isdst)= localtime($tm);
#main::debug "Adding $n months to $day.$month.$year $hour:$minute:$second= " . ts($tm); #main::Debug "Adding $n months to $day.$month.$year $hour:$minute:$second= " . ts($tm);
$month+= $n; $month+= $n;
$year+= int($month / 12); $year+= int($month / 12);
$month %= 12; $month %= 12;
#main::debug " gives $day.$month.$year $hour:$minute:$second= " . ts(main::fhemTimeLocal($second,$minute,$hour,$day,$month,$year)); #main::Debug " gives $day.$month.$year $hour:$minute:$second= " . ts(main::fhemTimeLocal($second,$minute,$hour,$day,$month,$year));
return main::fhemTimeLocal($second,$minute,$hour,$day,$month,$year); return main::fhemTimeLocal($second,$minute,$hour,$day,$month,$year);
} }
@ -380,7 +375,7 @@ sub fromVEvent {
my @keywords= qw(FREQ INTERVAL UNTIL COUNT BYMONTHDAY BYDAY BYMONTH); my @keywords= qw(FREQ INTERVAL UNTIL COUNT BYMONTHDAY BYDAY BYMONTH);
foreach my $k (keys %r) { foreach my $k (keys %r) {
if(not($k ~~ @keywords)) { if(not($k ~~ @keywords)) {
main::Log 2, "Calendar: RRULE $rrule is not supported"; main::Log3 undef, 2, "Calendar: RRULE $rrule is not supported";
} }
} }
@ -514,7 +509,7 @@ sub advanceToNextOccurance {
} elsif($self->{freq} eq "YEARLY") { } elsif($self->{freq} eq "YEARLY") {
$nextstart= plusNMonths($nextstart, 12*$self->{interval}); $nextstart= plusNMonths($nextstart, 12*$self->{interval});
} else { } else {
main::Log 1, "Calendar: event frequency '" . $self->{freq} . "' not implemented"; main::Log3 undef, 1, "Calendar: event frequency '" . $self->{freq} . "' not implemented";
return; return;
} }
@ -527,7 +522,7 @@ sub advanceToNextOccurance {
my $duration = $self->{end} - $self->{start}; my $duration = $self->{end} - $self->{start};
$self->{start} = $nextstart; $self->{start} = $nextstart;
$self->{end} = $self->{start} + $duration; $self->{end} = $self->{start} + $duration;
main::Log 5, "Next time of $self->{summary} is: start " . ts($self->{"start"}) . ", end " . ts($self->{"end"}); main::Log3 undef, 5, "Next time of $self->{summary} is: start " . ts($self->{"start"}) . ", end " . ts($self->{"end"});
return 1; return 1;
} }
@ -570,13 +565,13 @@ sub nextTime {
unshift @times, $self->{alarm} if($self->{alarm}); unshift @times, $self->{alarm} if($self->{alarm});
@times= sort grep { $_ > $t } @times; @times= sort grep { $_ > $t } @times;
# main::debug "Calendar: " . $self->asFull(); # main::Debug "Calendar: " . $self->asFull();
# main::debug "Calendar: Start " . main::FmtDateTime($self->{start}); # main::Debug "Calendar: Start " . main::FmtDateTime($self->{start});
# main::debug "Calendar: End " . main::FmtDateTime($self->{end}); # main::Debug "Calendar: End " . main::FmtDateTime($self->{end});
# main::debug "Calendar: Alarm " . main::FmtDateTime($self->{alarm}) if($self->{alarm}); # main::Debug "Calendar: Alarm " . main::FmtDateTime($self->{alarm}) if($self->{alarm});
# main::debug "Calendar: times[0] " . main::FmtDateTime($times[0]); # main::Debug "Calendar: times[0] " . main::FmtDateTime($times[0]);
# main::debug "Calendar: times[1] " . main::FmtDateTime($times[1]); # main::Debug "Calendar: times[1] " . main::FmtDateTime($times[1]);
# main::debug "Calendar: times[2] " . main::FmtDateTime($times[2]); # main::Debug "Calendar: times[2] " . main::FmtDateTime($times[2]);
if(@times) { if(@times) {
return $times[0]; return $times[0];
@ -652,20 +647,20 @@ sub updateFromCalendar {
$event->fromVEvent($vevent); $event->fromVEvent($vevent);
$uid= $event->uid(); $uid= $event->uid();
#main::debug "Processing event $uid."; #main::Debug "Processing event $uid.";
#foreach my $ee ($self->events()) { #foreach my $ee ($self->events()) {
# main::debug $ee->asFull(); # main::Debug $ee->asFull();
#} #}
if(defined($self->event($uid))) { if(defined($self->event($uid))) {
# the event already exists # the event already exists
#main::debug "Event $uid already exists."; #main::Debug "Event $uid already exists.";
$event->setState($self->event($uid)->state()); # copy the state from the existing event $event->setState($self->event($uid)->state()); # copy the state from the existing event
$event->setMode($self->event($uid)->mode()); # copy the mode from the existing event $event->setMode($self->event($uid)->mode()); # copy the mode from the existing event
#main::debug "Our lastModified: " . ts($self->event($uid)->lastModified()); #main::Debug "Our lastModified: " . ts($self->event($uid)->lastModified());
#main::debug "New lastModified: " . ts($event->lastModified()); #main::Debug "New lastModified: " . ts($event->lastModified());
if($self->event($uid)->lastModified() != $event->lastModified()) { if($self->event($uid)->lastModified() != $event->lastModified()) {
$event->setState("updated"); $event->setState("updated");
#main::debug "We set it to updated."; #main::Debug "We set it to updated.";
} else { } else {
$event->setState("known") $event->setState("known")
} }
@ -699,8 +694,7 @@ sub Calendar_Initialize($) {
$hash->{UndefFn} = "Calendar_Undef"; $hash->{UndefFn} = "Calendar_Undef";
$hash->{GetFn} = "Calendar_Get"; $hash->{GetFn} = "Calendar_Get";
$hash->{SetFn} = "Calendar_Set"; $hash->{SetFn} = "Calendar_Set";
$hash->{AttrList}= "loglevel:0,1,2,3,4,5 ". $hash->{AttrList}= $readingFnAttributes;
$readingFnAttributes;
} }
################################### ###################################
@ -709,7 +703,7 @@ sub Calendar_Wakeup($) {
my ($hash) = @_; my ($hash) = @_;
my $t= time(); my $t= time();
Log 4, "Calendar " . $hash->{NAME} . ": Wakeup"; Log3 $hash, 4, "Calendar " . $hash->{NAME} . ": Wakeup";
Calendar_GetUpdate($hash) if($t>= $hash->{fhem}{nxtUpdtTs}); Calendar_GetUpdate($hash) if($t>= $hash->{fhem}{nxtUpdtTs});
@ -740,7 +734,7 @@ sub Calendar_CheckTimes($) {
my $eventsObj= $hash->{fhem}{events}; my $eventsObj= $hash->{fhem}{events};
my $t= time(); my $t= time();
Log 4, "Calendar " . $hash->{NAME} . ": Checking times..."; Log3 $hash, 4, "Calendar " . $hash->{NAME} . ": Checking times...";
# we now run over all events and update the readings # we now run over all events and update the readings
my @allevents= $eventsObj->events(); my @allevents= $eventsObj->events();
@ -752,7 +746,7 @@ sub Calendar_CheckTimes($) {
my @startedevents= grep { $_->isStarted($t) } @allevents; my @startedevents= grep { $_->isStarted($t) } @allevents;
my $event; my $event;
#main::debug "Updating modes..."; #main::Debug "Updating modes...";
foreach $event (@upcomingevents) { $event->setMode("upcoming"); } foreach $event (@upcomingevents) { $event->setMode("upcoming"); }
foreach $event (@alarmedevents) { $event->setMode("alarm"); } foreach $event (@alarmedevents) { $event->setMode("alarm"); }
foreach $event (@startedevents) { $event->setMode("start"); } foreach $event (@startedevents) { $event->setMode("start"); }
@ -797,25 +791,25 @@ sub Calendar_GetUpdate($) {
$hash->{fhem}{lstUpdtTs}= $t; $hash->{fhem}{lstUpdtTs}= $t;
$hash->{fhem}{lastUpdate}= FmtDateTime($t); $hash->{fhem}{lastUpdate}= FmtDateTime($t);
Log 4, "Calendar " . $hash->{NAME} . ": Updating..."; Log3 $hash, 4, "Calendar " . $hash->{NAME} . ": Updating...";
my $url= $hash->{fhem}{url}; my $url= $hash->{fhem}{url};
my $ics= GetFileFromURLQuiet($url); my $ics= GetFileFromURLQuiet($url);
#my $ics= CustomGetFileFromURL(0, $url, undef, undef, 1); #my $ics= CustomGetFileFromURL(0, $url, undef, undef, 1);
if(!defined($ics)) { if(!defined($ics)) {
Log 1, "Calendar " . $hash->{NAME} . ": Could not retrieve file at URL"; Log3 $hash, 1, "Calendar " . $hash->{NAME} . ": Could not retrieve file at URL";
return 0; return 0;
} }
# we parse the calendar into a recursive ICal::Entry structure # we parse the calendar into a recursive ICal::Entry structure
my $ical= ICal::Entry->new("root"); my $ical= ICal::Entry->new("root");
$ical->parse(split("\n",$ics)); $ical->parse(split("\n",$ics));
#main::debug "*** Result:\n"; #main::Debug "*** Result:\n";
#main::debug $ical->asString(); #main::Debug $ical->asString();
my @entries= @{$ical->{entries}}; my @entries= @{$ical->{entries}};
if($#entries<0) { if($#entries<0) {
Log 1, "Calendar " . $hash->{NAME} . ": Not an ical file at URL"; Log3 $hash, 1, "Calendar " . $hash->{NAME} . ": Not an ical file at URL";
$hash->{STATE}= "Not an ical file at URL"; $hash->{STATE}= "Not an ical file at URL";
return 0; return 0;
}; };
@ -823,7 +817,7 @@ sub Calendar_GetUpdate($) {
my $root= @{$ical->{entries}}[0]; my $root= @{$ical->{entries}}[0];
my $calname= "?"; my $calname= "?";
if($root->{type} ne "VCALENDAR") { if($root->{type} ne "VCALENDAR") {
Log 1, "Calendar " . $hash->{NAME} . ": Root element is not a VCALENDAR"; Log3 $hash, 1, "Calendar " . $hash->{NAME} . ": Root element is not a VCALENDAR";
$hash->{STATE}= "Root element is not a VCALENDAR"; $hash->{STATE}= "Root element is not a VCALENDAR";
return 0; return 0;
} else { } else {
@ -834,7 +828,7 @@ sub Calendar_GetUpdate($) {
$hash->{STATE}= "Active"; $hash->{STATE}= "Active";
# we now create the events from it # we now create the events from it
#main::debug "Creating events..."; #main::Debug "Creating events...";
my $eventsObj= $hash->{fhem}{events}; my $eventsObj= $hash->{fhem}{events};
$eventsObj->updateFromCalendar($root); $eventsObj->updateFromCalendar($root);
$hash->{fhem}{events}= $eventsObj; $hash->{fhem}{events}= $eventsObj;
@ -878,7 +872,7 @@ sub Calendar_Set($@) {
Calendar_Wakeup($hash); Calendar_Wakeup($hash);
return undef; return undef;
} else { } else {
return "Unknown argument $cmd, choose one of update"; return "Unknown argument $cmd, choose one of update:noArg";
} }
} }
@ -961,7 +955,7 @@ sub Calendar_Define($$) {
$hash->{fhem}{interval}= $interval; $hash->{fhem}{interval}= $interval;
$hash->{fhem}{events}= Calendar::Events->new(); $hash->{fhem}{events}= Calendar::Events->new();
#main::debug "Interval: ${interval}s"; #main::Debug "Interval: ${interval}s";
$hash->{fhem}{nxtUpdtTs}= 0; $hash->{fhem}{nxtUpdtTs}= 0;
Calendar_Wakeup($hash); Calendar_Wakeup($hash);
@ -1158,7 +1152,7 @@ sub Calendar_Undef($$) {
</code><br><br> </code><br><br>
You can also do some logging:<br><br> You can also do some logging:<br><br>
<code> <code>
define LogErna notify MyCalendar:modeAlarmed.*2767324dsfretfvds7dsfn3e4&shy;dsa234r234sdfds6bh874&shy;googlecom.* { Log 1, "ALARM name=%NAME event=%EVENT part1=%EVTPART0 part2=%EVTPART1" } define LogErna notify MyCalendar:modeAlarmed.*2767324dsfretfvds7dsfn3e4&shy;dsa234r234sdfds6bh874&shy;googlecom.* { Log3 %NAME, 1, "ALARM name=%NAME event=%EVENT part1=%EVTPART0 part2=%EVTPART1" }
</code><br><br> </code><br><br>
</ul> </ul>
@ -1186,7 +1180,7 @@ sub Calendar_Undef($$) {
</code><br><br> </code><br><br>
You can also do some logging:<br><br> You can also do some logging:<br><br>
<code> <code>
define LogActors notify MyCalendar:mode(Started|Ended).* { my $reading= "%EVTPART0";; my $uid= "%EVTPART1";; my $actor= fhem("get MyCalendar summary $uid");; Log 1, "Actor: $actor, Reading $reading" } define LogActors notify MyCalendar:mode(Started|Ended).* { my $reading= "%EVTPART0";; my $uid= "%EVTPART1";; my $actor= fhem("get MyCalendar summary $uid");; Log 3 %NAME, 1, "Actor: $actor, Reading $reading" }
</code><br><br> </code><br><br>
</ul> </ul>

View File

@ -128,7 +128,7 @@ sub Weather_Initialize($) {
$hash->{UndefFn} = "Weather_Undef"; $hash->{UndefFn} = "Weather_Undef";
$hash->{GetFn} = "Weather_Get"; $hash->{GetFn} = "Weather_Get";
$hash->{SetFn} = "Weather_Set"; $hash->{SetFn} = "Weather_Set";
$hash->{AttrList}= "loglevel:0,1,2,3,4,5 localicons ". $hash->{AttrList}= "localicons ".
$readingFnAttributes; $readingFnAttributes;
} }
@ -165,7 +165,7 @@ sub Weather_UpdateReading($$$$) {
my ($hash,$prefix,$key,$value)= @_; my ($hash,$prefix,$key,$value)= @_;
#Log 1, "DEBUG WEATHER: $prefix $key $value"; #Debug "DEBUG WEATHER: $prefix $key $value";
my $unitsystem= $hash->{READINGS}{unit_system}{VAL}; my $unitsystem= $hash->{READINGS}{unit_system}{VAL};
@ -232,7 +232,7 @@ sub Weather_RetrieveData($)
foreach my $l (split("<",$xml)) { foreach my $l (split("<",$xml)) {
#Log 1, "DEBUG WEATHER: line=\"$l\""; #Debug "DEBUG WEATHER: line=\"$l\"";
next if($l eq ""); # skip empty lines next if($l eq ""); # skip empty lines
$l =~ s/(\/|\?)?>$//; # strip off /> and > $l =~ s/(\/|\?)?>$//; # strip off /> and >
my ($tag,$value)= split(" ", $l, 2); # split tag data=..... at the first blank my ($tag,$value)= split(" ", $l, 2); # split tag data=..... at the first blank
@ -344,7 +344,7 @@ sub Weather_GetUpdate($)
my $humidity= $hash->{READINGS}{humidity}{VAL}; my $humidity= $hash->{READINGS}{humidity}{VAL};
my $wind= $hash->{READINGS}{wind}{VAL}; my $wind= $hash->{READINGS}{wind}{VAL};
my $val= "T: $temperature H: $humidity W: $wind"; my $val= "T: $temperature H: $humidity W: $wind";
Log GetLogLevel($hash->{NAME},4), "Weather ". $hash->{NAME} . ": $val"; Log3 $hash, 4, "Weather ". $hash->{NAME} . ": $val";
readingsBulkUpdate($hash, "state", $val); readingsBulkUpdate($hash, "state", $val);
readingsEndUpdate($hash, defined($hash->{LOCAL} ? 0 : 1)); # DoTrigger, because sub is called by a timer instead of dispatch readingsEndUpdate($hash, defined($hash->{LOCAL} ? 0 : 1)); # DoTrigger, because sub is called by a timer instead of dispatch

View File

@ -32,7 +32,7 @@ M232_Initialize($)
$hash->{UndefFn} = "M232_Undef"; $hash->{UndefFn} = "M232_Undef";
$hash->{GetFn} = "M232_Get"; $hash->{GetFn} = "M232_Get";
$hash->{SetFn} = "M232_Set"; $hash->{SetFn} = "M232_Set";
$hash->{AttrList}= "model:m232 loglevel:0,1,2,3,4,5"; $hash->{AttrList}= "model:m232";
} }
##################################### #####################################
@ -46,17 +46,17 @@ M232_Define($$)
my $dev = $a[2]; my $dev = $a[2];
if($dev eq "none") { if($dev eq "none") {
Log 1, "M232 device is none, commands will be echoed only"; Log3 $hash, 1, "M232 device is none, commands will be echoed only";
return undef; return undef;
} }
Log 3, "M232 opening device $dev"; Log3 $hash, 3, "M232 opening device $dev";
my $po; my $po;
if ($^O eq 'MSWin32') { if ($^O eq 'MSWin32') {
eval ("use Win32::SerialPort;"); eval ("use Win32::SerialPort;");
if ($@) { if ($@) {
$hash->{STATE} = "error using Modul Win32::SerialPort"; $hash->{STATE} = "error using Modul Win32::SerialPort";
Log 1,"Error using Device::SerialPort"; Log3 $hash, 1,"Error using Device::SerialPort";
return "Can't use Win32::SerialPort $@\n"; return "Can't use Win32::SerialPort $@\n";
} }
$po = new Win32::SerialPort ($dev, 1); $po = new Win32::SerialPort ($dev, 1);
@ -65,18 +65,18 @@ M232_Define($$)
eval ("use Device::SerialPort;"); eval ("use Device::SerialPort;");
if ($@) { if ($@) {
$hash->{STATE} = "error using Modul Device::SerialPort"; $hash->{STATE} = "error using Modul Device::SerialPort";
Log 1,"Error using Device::SerialPort"; Log3 $hash, 1,"Error using Device::SerialPort";
return "Can't Device::SerialPort $@\n"; return "Can't Device::SerialPort $@\n";
} }
$po = new Device::SerialPort ($dev, 1); $po = new Device::SerialPort ($dev, 1);
} }
if (!$po) { if (!$po) {
$hash->{STATE} = "error opening device"; $hash->{STATE} = "error opening device";
Log 1,"Error opening Serial Device $dev"; Log3 $hash, 1,"Error opening Serial Device $dev";
return "Can't open Device $dev: $^E\n"; return "Can't open Device $dev: $^E\n";
} }
Log 3, "M232 opened device $dev"; Log3 $hash, 3, "M232 opened device $dev";
$po->close(); $po->close();
$hash->{DeviceName} = $dev; $hash->{DeviceName} = $dev;
@ -96,7 +96,7 @@ M232_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 $hash, $lev, "deleting port for $d";
delete $defs{$d}{IODev}; delete $defs{$d}{IODev};
} }
} }
@ -272,7 +272,7 @@ M232GetData($$)
$serport=new Device::SerialPort ($dev, 1); $serport=new Device::SerialPort ($dev, 1);
} }
if(!$serport) { if(!$serport) {
Log 3, "M232: Can't open $dev: $!"; Log3 $hash, 3, "M232: Can't open $dev: $!";
return undef; return undef;
} }
$serport->reset_error(); $serport->reset_error();
@ -283,7 +283,7 @@ M232GetData($$)
$serport->handshake('none'); $serport->handshake('none');
$serport->write_settings; $serport->write_settings;
$hash->{po}=$serport; $hash->{po}=$serport;
Log 4, "M232: Sending $d"; Log3 $hash, 4, "M232: Sending $d";
my $rm = "M232: ?"; my $rm = "M232: ?";
@ -319,7 +319,7 @@ M232GetData($$)
if($out eq $MSGACK) { if($out eq $MSGACK) {
$rm= "M232: acknowledged"; $rm= "M232: acknowledged";
Log 4, "M232: return value \'" . $retval . "\'"; Log3 $hash, 4, "M232: return value \'" . $retval . "\'";
$status= "ACK"; $status= "ACK";
} elsif($out eq $MSGNACK) { } elsif($out eq $MSGNACK) {
$rm= "M232: not acknowledged"; $rm= "M232: not acknowledged";
@ -340,7 +340,7 @@ DONE:
$serport->close(); $serport->close();
undef $serport; undef $serport;
delete $hash->{po} if exists($hash->{po}); delete $hash->{po} if exists($hash->{po});
Log 4, $rm; Log3 $hash, 4, $rm;
return $ret; return $ret;
} }
@ -423,7 +423,6 @@ DONE:
<a name="M232attr"></a> <a name="M232attr"></a>
<b>Attributes</b> <b>Attributes</b>
<ul> <ul>
<li><a href="#loglevel">loglevel</a></li>
<li><a href="#model">model</a> (m232)</li> <li><a href="#model">model</a> (m232)</li>
</ul> </ul>
<br> <br>

View File

@ -28,7 +28,7 @@ M232Counter_Initialize($)
$hash->{SetFn} = "M232Counter_Set"; $hash->{SetFn} = "M232Counter_Set";
$hash->{DefFn} = "M232Counter_Define"; $hash->{DefFn} = "M232Counter_Define";
$hash->{AttrList} = "dummy:1,0 model:M232Counter loglevel:0,1,2,3,4,5"; $hash->{AttrList} = "dummy:1,0 model:M232Counter";
} }
################################### ###################################
@ -47,7 +47,7 @@ M232Counter_GetStatus($)
my $d = IOWrite($hash, "z"); my $d = IOWrite($hash, "z");
if(!defined($d)) { if(!defined($d)) {
my $msg = "M232Counter $name tick count read error"; my $msg = "M232Counter $name tick count read error";
Log GetLogLevel($name,2), $msg; Log3 $name, 2, $msg;
return $msg; return $msg;
} }
@ -96,7 +96,7 @@ M232Counter_GetStatus($)
my $ret = IOWrite($hash, "Z1"); my $ret = IOWrite($hash, "Z1");
if(!defined($ret)) { if(!defined($ret)) {
my $msg = "M232Counter $name reset error"; my $msg = "M232Counter $name reset error";
Log GetLogLevel($name,2), $msg; Log3 $name, 2, $msg;
return $msg; return $msg;
} }
} }
@ -143,7 +143,7 @@ M232Counter_GetStatus($)
} }
$hash->{STATE} = $value; $hash->{STATE} = $value;
Log GetLogLevel($name,4), "M232Counter $name: $value $hash->{UNIT}"; Log3 $name, 4, "M232Counter $name: $value $hash->{UNIT}";
return $hash->{STATE}; return $hash->{STATE};
} }
@ -192,7 +192,7 @@ M232Counter_Calibrate($@)
my $ret = IOWrite($hash, "Z1"); my $ret = IOWrite($hash, "Z1");
if(!defined($ret)) { if(!defined($ret)) {
my $rm = "M232Counter $name read error"; my $rm = "M232Counter $name read error";
Log GetLogLevel($name,2), $rm; Log3 $name, 2, $rm;
} }
return $rm; return $rm;
@ -331,7 +331,6 @@ M232Counter_Define($$)
<b>Attributes</b> <b>Attributes</b>
<ul> <ul>
<li><a href="#attrdummy">dummy</a></li><br> <li><a href="#attrdummy">dummy</a></li><br>
<li><a href="#loglevel">loglevel</a></li>
<li><a href="#model">model</a> (M232Counter)</li> <li><a href="#model">model</a> (M232Counter)</li>
</ul> </ul>
<br> <br>

View File

@ -25,7 +25,7 @@ M232Voltage_Initialize($)
$hash->{GetFn} = "M232Voltage_Get"; $hash->{GetFn} = "M232Voltage_Get";
$hash->{DefFn} = "M232Voltage_Define"; $hash->{DefFn} = "M232Voltage_Define";
$hash->{AttrList} = "dummy:1,0 model:M232Voltage loglevel:0,1,2,3,4,5"; $hash->{AttrList} = "dummy:1,0 model:M232Voltage";
} }
################################### ###################################
@ -43,7 +43,7 @@ M232Voltage_GetStatus($)
my $d = IOWrite($hash, "a" . $hash->{INPUT}); my $d = IOWrite($hash, "a" . $hash->{INPUT});
if(!defined($d)) { if(!defined($d)) {
my $msg = "M232Voltage $name read error"; my $msg = "M232Voltage $name read error";
Log GetLogLevel($name,2), $msg; Log3 $name, 2, $msg;
return $msg; return $msg;
} }
@ -60,7 +60,7 @@ M232Voltage_GetStatus($)
} }
$hash->{STATE} = $value; $hash->{STATE} = $value;
Log GetLogLevel($name,4), "M232Voltage $name: $value $hash->{UNIT}"; Log3 $name, 4, "M232Voltage $name: $value $hash->{UNIT}";
return $hash->{STATE}; return $hash->{STATE};
} }
@ -160,7 +160,6 @@ M232Voltage_Define($$)
<b>Attributes</b> <b>Attributes</b>
<ul> <ul>
<li><a href="#attrdummy">dummy</a></li><br> <li><a href="#attrdummy">dummy</a></li><br>
<li><a href="#loglevel">loglevel</a></li>
<li><a href="#model">model</a> (M232Voltage)</li> <li><a href="#model">model</a> (M232Voltage)</li>
</ul> </ul>
<br> <br>