mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-04-27 10:37:13 +00:00
00_TCM: Improved initialization behavior
git-svn-id: https://svn.fhem.de/fhem/trunk@19412 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
357279f888
commit
d39b17e0c5
@ -32,11 +32,8 @@ sub TCM_Parse310($$$);
|
|||||||
sub TCM_CRC8($);
|
sub TCM_CRC8($);
|
||||||
sub TCM_CSUM($);
|
sub TCM_CSUM($);
|
||||||
|
|
||||||
sub
|
sub TCM_Initialize($) {
|
||||||
TCM_Initialize($)
|
|
||||||
{
|
|
||||||
my ($hash) = @_;
|
my ($hash) = @_;
|
||||||
|
|
||||||
require "$attr{global}{modpath}/FHEM/DevIo.pm";
|
require "$attr{global}{modpath}/FHEM/DevIo.pm";
|
||||||
|
|
||||||
# Provider
|
# Provider
|
||||||
@ -61,11 +58,11 @@ TCM_Initialize($)
|
|||||||
"dummy:1,0 fingerprint:off,on learningDev:all,teachMsg learningMode:always,demand,nearfield " .
|
"dummy:1,0 fingerprint:off,on learningDev:all,teachMsg learningMode:always,demand,nearfield " .
|
||||||
"sendInterval:0,25,40,50,100,150,200,250 smartAckMailboxMax:slider,0,1,20 " .
|
"sendInterval:0,25,40,50,100,150,200,250 smartAckMailboxMax:slider,0,1,20 " .
|
||||||
"smartAckLearnMode:simple,advance,advanceSelectRep";
|
"smartAckLearnMode:simple,advance,advanceSelectRep";
|
||||||
|
$hash->{NotifyOrderPrefix} = "45-";
|
||||||
}
|
}
|
||||||
|
|
||||||
# Define
|
# Define
|
||||||
sub TCM_Define($$)
|
sub TCM_Define($$){
|
||||||
{
|
|
||||||
my ($hash, $def) = @_;
|
my ($hash, $def) = @_;
|
||||||
my @a = split("[ \t][ \t]*", $def);
|
my @a = split("[ \t][ \t]*", $def);
|
||||||
my $name = $a[0];
|
my $name = $a[0];
|
||||||
@ -95,9 +92,7 @@ sub TCM_Define($$)
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Initialize serial communication
|
# Initialize serial communication
|
||||||
sub
|
sub TCM_InitSerialCom($) {
|
||||||
TCM_InitSerialCom($)
|
|
||||||
{
|
|
||||||
my ($hash) = @_;
|
my ($hash) = @_;
|
||||||
my $name = $hash->{NAME};
|
my $name = $hash->{NAME};
|
||||||
if ($hash->{STATE} eq "disconnected") {
|
if ($hash->{STATE} eq "disconnected") {
|
||||||
@ -119,7 +114,7 @@ TCM_InitSerialCom($)
|
|||||||
} else {
|
} else {
|
||||||
#TCM_ReadAnswer($hash, "set reset");
|
#TCM_ReadAnswer($hash, "set reset");
|
||||||
#TCM_Read($hash);
|
#TCM_Read($hash);
|
||||||
#$hash->{PARTIAL} = '';
|
$hash->{PARTIAL} = '';
|
||||||
delete $hash->{helper}{awaitCmdResp};
|
delete $hash->{helper}{awaitCmdResp};
|
||||||
TCM_Set($hash, @setCmd);
|
TCM_Set($hash, @setCmd);
|
||||||
}
|
}
|
||||||
@ -139,14 +134,15 @@ TCM_InitSerialCom($)
|
|||||||
Log3 $name, 2, "TCM $name Attribute $_ $setAttrInit{$_}{$hash->{MODEL}} initialized";
|
Log3 $name, 2, "TCM $name Attribute $_ $setAttrInit{$_}{$hash->{MODEL}} initialized";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
# 500 ms pause
|
# 750 ms pause
|
||||||
usleep(500 * 1000);
|
usleep(750 * 1000);
|
||||||
# read transceiver IDs
|
# read transceiver IDs
|
||||||
my $baseID = AttrVal($name, "baseID", undef);
|
my $baseID = AttrVal($name, "baseID", undef);
|
||||||
if (defined($baseID)) {
|
if (defined($baseID)) {
|
||||||
$hash->{BaseID} = $baseID;
|
$hash->{BaseID} = $baseID;
|
||||||
$hash->{LastID} = sprintf "%08X", (hex $baseID) + 127;
|
$hash->{LastID} = sprintf "%08X", (hex $baseID) + 127;
|
||||||
} elsif ($comType ne "RS485" && $hash->{DeviceName} ne "none") {
|
} elsif ($comType ne "RS485" && $hash->{DeviceName} ne "none") {
|
||||||
|
#$hash->{PARTIAL} = '';
|
||||||
my @getBaseID = ("get", "baseID");
|
my @getBaseID = ("get", "baseID");
|
||||||
if (TCM_Get($hash, @getBaseID) =~ /[Ff]{2}[\dA-Fa-f]{6}/) {
|
if (TCM_Get($hash, @getBaseID) =~ /[Ff]{2}[\dA-Fa-f]{6}/) {
|
||||||
$hash->{BaseID} = sprintf "%08X", hex $&;
|
$hash->{BaseID} = sprintf "%08X", hex $&;
|
||||||
@ -158,6 +154,7 @@ TCM_InitSerialCom($)
|
|||||||
}
|
}
|
||||||
if ($hash->{MODEL} eq "ESP3" && $comType ne "RS485" && $hash->{DeviceName} ne "none") {
|
if ($hash->{MODEL} eq "ESP3" && $comType ne "RS485" && $hash->{DeviceName} ne "none") {
|
||||||
# get chipID
|
# get chipID
|
||||||
|
#$hash->{PARTIAL} = '';
|
||||||
my @getChipID = ('get', 'version');
|
my @getChipID = ('get', 'version');
|
||||||
if (TCM_Get($hash, @getChipID) =~ m/ChipID:.([\dA-Fa-f]{8})/) {
|
if (TCM_Get($hash, @getChipID) =~ m/ChipID:.([\dA-Fa-f]{8})/) {
|
||||||
$hash->{ChipID} = sprintf "%08X", hex $1;
|
$hash->{ChipID} = sprintf "%08X", hex $1;
|
||||||
@ -395,7 +392,7 @@ TCM_Read($)
|
|||||||
my $rest = substr($data, 28);
|
my $rest = substr($data, 28);
|
||||||
|
|
||||||
if($crc ne $mycrc) {
|
if($crc ne $mycrc) {
|
||||||
Log3 $name, 2, "TCM $name wrong checksum: got $crc, computed $mycrc" ;
|
Log3 $name, 2, "TCM $name wrong data checksum: got $crc, computed $mycrc" ;
|
||||||
$data = $rest;
|
$data = $rest;
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
@ -1099,7 +1096,7 @@ sub TCM_ReadAnswer($$)
|
|||||||
my $mycrc = TCM_CSUM($net);
|
my $mycrc = TCM_CSUM($net);
|
||||||
$hash->{PARTIAL} = substr($data, 28);
|
$hash->{PARTIAL} = substr($data, 28);
|
||||||
if ($crc ne $mycrc) {
|
if ($crc ne $mycrc) {
|
||||||
return ("wrong checksum: got $crc, computed $mycrc", undef);
|
return ("wrong data checksum: got $crc, computed $mycrc", undef);
|
||||||
}
|
}
|
||||||
return (undef, $net);
|
return (undef, $net);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user