mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-01-31 18:59:33 +00:00
# logging changed to Log3
git-svn-id: https://svn.fhem.de/fhem/trunk@3885 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
ade1dafc67
commit
b47bcb3f9b
@ -54,7 +54,7 @@ TCM_Initialize($)
|
||||
$hash->{UndefFn} = "TCM_Undef";
|
||||
$hash->{GetFn} = "TCM_Get";
|
||||
$hash->{SetFn} = "TCM_Set";
|
||||
$hash->{AttrList}= "do_not_notify:1,0 dummy:1,0 loglevel:0,1,2,3,4,5,6 blockSenderID:own,no";
|
||||
$hash->{AttrList}= "do_not_notify:1,0 dummy:1,0 blockSenderID:own,no";
|
||||
}
|
||||
|
||||
# Define
|
||||
@ -102,8 +102,6 @@ TCM_Write($$$)
|
||||
{
|
||||
my ($hash,$fn,$msg) = @_;
|
||||
my $name = $hash->{NAME};
|
||||
my $ll2 = GetLogLevel($name,2);
|
||||
my $ll5 = GetLogLevel($name,5);
|
||||
|
||||
return if(!defined($fn));
|
||||
|
||||
@ -117,12 +115,12 @@ TCM_Write($$$)
|
||||
# command with ESP3 format
|
||||
my $packetType = hex(substr($fn, 6, 2));
|
||||
if ($packetType != 1) {
|
||||
Log $ll2, "TCM120 $name: Packet Type not supported.";
|
||||
Log3 $name, 2, "TCM120 $name: Packet Type not supported.";
|
||||
return;
|
||||
}
|
||||
my $odataLen = hex(substr($fn, 4, 2));
|
||||
if ($odataLen != 0) {
|
||||
Log $ll2, "TCM120 $name: Radio Telegram with optional Data not supported.";
|
||||
Log3 $name, 2, "TCM120 $name: Radio Telegram with optional Data not supported.";
|
||||
return;
|
||||
}
|
||||
#my $mdataLen = hex(substr($fn, 0, 4));
|
||||
@ -135,7 +133,7 @@ TCM_Write($$$)
|
||||
if($rorgmap{$rorg}) {
|
||||
$rorg = $rorgmap{$rorg};
|
||||
} else {
|
||||
Log $ll2, "TCM120 $name: unknown RORG mapping for $rorg";
|
||||
Log3 $name, 2, "TCM120 $name: unknown RORG mapping for $rorg";
|
||||
}
|
||||
if ($rorg eq "05" || $rorg eq "06") {
|
||||
$bstring = "6B" . $rorg . substr ($msg, 2, 2) . "000000" . substr ($msg, 4);
|
||||
@ -148,7 +146,7 @@ TCM_Write($$$)
|
||||
# TCM 310 (ESP3)
|
||||
$bstring = "55" . $fn . TCM_CRC8($fn) . $msg . TCM_CRC8($msg);
|
||||
}
|
||||
Log $ll5, "TCM: $name sending $bstring";
|
||||
Log3 $name, 5, "TCM: $name sending $bstring";
|
||||
DevIo_SimpleWrite($hash, $bstring, 1);
|
||||
}
|
||||
|
||||
@ -223,11 +221,9 @@ TCM_Read($)
|
||||
my $blockSenderID = ReadingsVal($name, "blockSenderID", "no");
|
||||
my $baseID = hex $hash->{BaseID};
|
||||
my $lastID = hex $hash->{LastID};
|
||||
my $ll5 = GetLogLevel($name, 5);
|
||||
my $ll2 = GetLogLevel($name, 2);
|
||||
|
||||
my $data = $hash->{PARTIAL} . uc(unpack('H*', $buf));
|
||||
Log $ll5, "$name/RAW: $data";
|
||||
Log3 $name, 5, "TCM: $name/RAW: $data";
|
||||
|
||||
if($hash->{MODEL} == 120) {
|
||||
# TCM 120
|
||||
@ -238,7 +234,7 @@ TCM_Read($)
|
||||
my $rest = substr($data, 28);
|
||||
|
||||
if($crc ne $mycrc) {
|
||||
Log $ll2, "TCM: $name wrong checksum: got $crc, computed $mycrc" ;
|
||||
Log3 $name, 2, "TCM: $name wrong checksum: got $crc, computed $mycrc" ;
|
||||
$data = $rest;
|
||||
next;
|
||||
}
|
||||
@ -259,7 +255,7 @@ TCM_Read($)
|
||||
$d1 = substr($d1, 0, 2);
|
||||
}
|
||||
if ($blockSenderID eq "own" && (hex $id) >= $baseID && (hex $id) <= $lastID) {
|
||||
Log $ll5, "TCM: $name Telegram from $id blocked.";
|
||||
Log3 $name, 5, "TCM: $name Telegram from $id blocked.";
|
||||
} else {
|
||||
Dispatch($hash, "EnOcean:$packetType:$org:$d1:$id:$status", undef);
|
||||
}
|
||||
@ -295,14 +291,14 @@ TCM_Read($)
|
||||
|
||||
my $mycrc = TCM_CRC8($hdr);
|
||||
if($mycrc ne $crc) {
|
||||
Log $ll2, "TCM: $name wrong header checksum: got $crc, computed $mycrc" ;
|
||||
Log3 $name, 2, "TCM: $name wrong header checksum: got $crc, computed $mycrc" ;
|
||||
$data = $rest;
|
||||
next;
|
||||
}
|
||||
$mycrc = TCM_CRC8($mdata . $odata);
|
||||
$crc = substr($data, -2);
|
||||
if($mycrc ne $crc) {
|
||||
Log $ll2, "TCM: $name wrong data checksum: got $crc, computed $mycrc" ;
|
||||
Log3 $name, 2, "TCM: $name wrong data checksum: got $crc, computed $mycrc" ;
|
||||
$data = $rest;
|
||||
next;
|
||||
}
|
||||
@ -323,7 +319,7 @@ TCM_Read($)
|
||||
$hash->{RSSI} = -hex($3);
|
||||
|
||||
if ($blockSenderID eq "own" && (hex $id) >= $baseID && (hex $id) <= $lastID) {
|
||||
Log $ll5, "TCM: $name Telegram from $id blocked.";
|
||||
Log3 $name, 5, "TCM: $name Telegram from $id blocked.";
|
||||
} else {
|
||||
Dispatch($hash, "EnOcean:$packetType:$org:$d1:$id:$status:$odata", \%addvals);
|
||||
}
|
||||
@ -342,30 +338,31 @@ TCM_Read($)
|
||||
"91" => "BASEID_MAX_REACHED",
|
||||
);
|
||||
$rc = $codes{$rc} if($codes{$rc});
|
||||
Log (($rc eq "OK") ? $ll5 : $ll2, "TCM: $name RESPONSE: $rc");
|
||||
#Log (($rc eq "OK") ? $ll5 : $ll2, "TCM: $name RESPONSE: $rc");
|
||||
Log3 ($name, ($rc eq "OK") ? 5 : 2, "TCM: $name RESPONSE: $rc");
|
||||
|
||||
} elsif($packetType == 3) {
|
||||
# packet type RADIO_SUB_TEL
|
||||
Log $ll2, "TCM: $name packet type RADIO_SUB_TEL not supported: $data";
|
||||
Log3 $name, 2, "TCM: $name packet type RADIO_SUB_TEL not supported: $data";
|
||||
|
||||
} elsif($packetType == 4) {
|
||||
# packet type EVENT
|
||||
Log $ll2, "TCM: $name packet type EVENT not supported: $data";
|
||||
Log3 $name, 2, "TCM: $name packet type EVENT not supported: $data";
|
||||
|
||||
} elsif($packetType == 5) {
|
||||
# packet type COMMON_COMMAND
|
||||
Log $ll2, "TCM: $name packet type COMMON_COMMAND not supported: $data";
|
||||
Log3 $name, 2, "TCM: $name packet type COMMON_COMMAND not supported: $data";
|
||||
|
||||
} elsif($packetType == 6) {
|
||||
# packet type SMART_ACK_COMMAND
|
||||
Log $ll2, "TCM: $name packet type SMART_ACK_COMMAND not supported: $data";
|
||||
Log3 $name, 2, "TCM: $name packet type SMART_ACK_COMMAND not supported: $data";
|
||||
|
||||
} elsif($packetType == 7) {
|
||||
# packet type REMOTE_MAN_COMMAND
|
||||
Log $ll2, "TCM: $name packet type REMOTE_MAN_COMMAND not supported: $data";
|
||||
Log3 $name, 2, "TCM: $name packet type REMOTE_MAN_COMMAND not supported: $data";
|
||||
|
||||
} else {
|
||||
Log $ll2, "TCM: $name unknown packet type $packetType: $data";
|
||||
Log3 $name, 2, "TCM: $name unknown packet type $packetType: $data";
|
||||
|
||||
}
|
||||
|
||||
@ -409,10 +406,8 @@ TCM_Parse120($$$)
|
||||
{
|
||||
my ($hash,$rawmsg,$ret) = @_;
|
||||
my $name = $hash->{NAME};
|
||||
my $ll5 = GetLogLevel($name,5);
|
||||
my $ll2 = GetLogLevel($name,2);
|
||||
|
||||
Log $ll5, "TCM: Parse $rawmsg";
|
||||
Log3 $name, 5, "TCM: Parse $rawmsg";
|
||||
|
||||
my $msg = "";
|
||||
my $cmd = $parsetbl120{substr($rawmsg, 0, 4)};
|
||||
@ -436,7 +431,7 @@ TCM_Parse120($$$)
|
||||
|
||||
}
|
||||
|
||||
Log $ll2, "TCM: $name $msg" if(!$ret);
|
||||
Log3 $name, 2, "TCM: $name $msg" if(!$ret);
|
||||
return $msg;
|
||||
}
|
||||
|
||||
@ -458,9 +453,7 @@ TCM_Parse310($$$)
|
||||
{
|
||||
my ($hash,$rawmsg,$ptr) = @_;
|
||||
my $name = $hash->{NAME};
|
||||
my $ll5 = GetLogLevel($name,5);
|
||||
my $ll2 = GetLogLevel($name,2);
|
||||
Log $ll5, "TCM: Parse $rawmsg";
|
||||
Log3 $name, 5, "TCM: Parse $rawmsg";
|
||||
my $rc = substr($rawmsg, 0, 2);
|
||||
my $msg = "";
|
||||
|
||||
@ -479,7 +472,7 @@ TCM_Parse310($$$)
|
||||
$msg = join(",", @ans);
|
||||
}
|
||||
|
||||
Log $ll2, "TCM: $name $msg";
|
||||
Log3 $name, 2, "TCM: $name $msg";
|
||||
return $msg;
|
||||
}
|
||||
|
||||
@ -688,7 +681,6 @@ TCM_ReadAnswer($$)
|
||||
{
|
||||
my ($hash, $arg) = @_;
|
||||
my $name = $hash->{NAME};
|
||||
my $ll5 = GetLogLevel($name,5);
|
||||
|
||||
return ("No FD", undef)
|
||||
if(!$hash || ($^O !~ /Win/ && !defined($hash->{FD})));
|
||||
@ -724,7 +716,7 @@ TCM_ReadAnswer($$)
|
||||
|
||||
if(defined($buf)) {
|
||||
$data .= uc(unpack('H*', $buf));
|
||||
Log $ll5, "TCM/RAW (ReadAnswer): $data";
|
||||
Log3 $name, 5, "TCM/RAW (ReadAnswer): $data";
|
||||
|
||||
if($hash->{MODEL} eq "120") {
|
||||
# TCM 120
|
||||
|
Loading…
Reference in New Issue
Block a user