mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-04-19 12:46:03 +00:00
Initial support for sispmctl V3 (new output format)
git-svn-id: https://svn.fhem.de/fhem/trunk@1210 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
964c39ec36
commit
4046acd406
@ -44,7 +44,7 @@ SIS_PMS_Initialize($)
|
|||||||
{
|
{
|
||||||
my ($hash) = @_;
|
my ($hash) = @_;
|
||||||
|
|
||||||
$hash->{Match} = "^socket ..:..:..:..:.. . state o.*";
|
$hash->{Match} = "^socket ..:..:..:..:.. .+ state o.*";
|
||||||
$hash->{SetFn} = "SIS_PMS_Set";
|
$hash->{SetFn} = "SIS_PMS_Set";
|
||||||
# $hash->{StateFn} = "SIS_PMS_SetState";
|
# $hash->{StateFn} = "SIS_PMS_SetState";
|
||||||
$hash->{DefFn} = "SIS_PMS_Define";
|
$hash->{DefFn} = "SIS_PMS_Define";
|
||||||
@ -141,8 +141,13 @@ SIS_PMS_Parse($$)
|
|||||||
|
|
||||||
$devname =~ s/:/_/g;
|
$devname =~ s/:/_/g;
|
||||||
Log 3, "SIS_PMS Unknown device $serial $socknr, please define it";
|
Log 3, "SIS_PMS Unknown device $serial $socknr, please define it";
|
||||||
|
if(defined($hash->{TMPLABEL})) {
|
||||||
|
$devname=$hash->{TMPLABEL};
|
||||||
|
return "UNDEFINED $devname SIS_PMS $serial $socknr";
|
||||||
|
} else {
|
||||||
return "UNDEFINED SIS_PMS_$devname.$socknr SIS_PMS $serial $socknr";
|
return "UNDEFINED SIS_PMS_$devname.$socknr SIS_PMS $serial $socknr";
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ SISPM_Initialize($)
|
|||||||
$hash->{Clients} =
|
$hash->{Clients} =
|
||||||
":SIS_PMS:";
|
":SIS_PMS:";
|
||||||
my %mc = (
|
my %mc = (
|
||||||
"1:SIS_PMS" => "^socket ..:..:..:..:.. . state o.*",
|
"1:SIS_PMS" => "^socket ..:..:..:..:.. .+ state o.*",
|
||||||
);
|
);
|
||||||
$hash->{MatchList} = \%mc;
|
$hash->{MatchList} = \%mc;
|
||||||
$hash->{AttrList}= "model:SISPM loglevel:0,1,2,3,4,5,6";
|
$hash->{AttrList}= "model:SISPM loglevel:0,1,2,3,4,5,6";
|
||||||
@ -111,6 +111,7 @@ SISPM_GetCurrentConfig($)
|
|||||||
return "Can't start $tmpdev: $!";
|
return "Can't start $tmpdev: $!";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
my $tmpnr=-1;
|
||||||
local $_;
|
local $_;
|
||||||
while (<$FH>) {
|
while (<$FH>) {
|
||||||
if(/^(No GEMBIRD SiS-PM found.)/) {
|
if(/^(No GEMBIRD SiS-PM found.)/) {
|
||||||
@ -124,6 +125,16 @@ SISPM_GetCurrentConfig($)
|
|||||||
$numdetected++;
|
$numdetected++;
|
||||||
$hash->{NUMUNITS}=$numdetected;
|
$hash->{NUMUNITS}=$numdetected;
|
||||||
}
|
}
|
||||||
|
if(/^Gembird #(\d+)$/) {
|
||||||
|
Log 3, "SISPM_GetCurrentConfig: Found SISPM device number $1 (sispmctl v3)";
|
||||||
|
$currentdevice=$1;
|
||||||
|
$numdetected++;
|
||||||
|
$hash->{NUMUNITS}=$numdetected;
|
||||||
|
}
|
||||||
|
if(/^USB information: bus .*, device (\d+)/) {
|
||||||
|
Log 3, "SISPM_GetCurrentConfig: SISPM device number $currentdevice is USB device $1 (sispmctl v3)";
|
||||||
|
$hash->{UNITS}{$currentdevice}{USB}=$1;
|
||||||
|
}
|
||||||
|
|
||||||
if(/^This device has a serial number of (.*)/) {
|
if(/^This device has a serial number of (.*)/) {
|
||||||
my $serial=$1;
|
my $serial=$1;
|
||||||
@ -136,13 +147,24 @@ SISPM_GetCurrentConfig($)
|
|||||||
$hash->{SERIALS}{$serial}{UNIT}=$currentdevice;
|
$hash->{SERIALS}{$serial}{UNIT}=$currentdevice;
|
||||||
$hash->{SERIALS}{$serial}{USB}=$hash->{UNITS}{$currentdevice}{USB};
|
$hash->{SERIALS}{$serial}{USB}=$hash->{UNITS}{$currentdevice}{USB};
|
||||||
}
|
}
|
||||||
|
if(/^serial number:\s+(.*)/) { # sispmctl v3
|
||||||
|
my $serial=$1;
|
||||||
|
Log 3, "SISPM_GetCurrentConfig: Device number " . $currentdevice . " has serial $serial (sispmctl v3)";
|
||||||
|
if(length($serial)!=length("..:..:..:..:..")){
|
||||||
|
$serial = FixSISPMSerial($serial);
|
||||||
|
Log 3, "SISPM_GetCurrentConfig: Whoopsi, weird serial format; fixing to $serial.";
|
||||||
|
}
|
||||||
|
$hash->{UNITS}{$currentdevice}{SERIAL}=$serial;
|
||||||
|
$hash->{SERIALS}{$serial}{UNIT}=$currentdevice;
|
||||||
|
$hash->{SERIALS}{$serial}{USB}=$hash->{UNITS}{$currentdevice}{USB};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
close($FH);
|
close($FH);
|
||||||
Log 3, "SISPM_GetCurrentConfig: Initial read done";
|
Log 3, "SISPM_GetCurrentConfig: Initial read done";
|
||||||
|
|
||||||
if ($numdetected==0) {
|
if ($numdetected==0) {
|
||||||
Log 3, "SISPM_GetCurrentConfig: No SIMPM devices found.";
|
Log 3, "SISPM_GetCurrentConfig: No SISPM devices found.";
|
||||||
return "no SIMPM devices found.";
|
return "no SISPM devices found.";
|
||||||
}
|
}
|
||||||
|
|
||||||
$hash->{NUMUNITS} = $numdetected;
|
$hash->{NUMUNITS} = $numdetected;
|
||||||
@ -178,7 +200,7 @@ SISPM_Define($$)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if($hash->{NUMUNITS} < 1) {
|
if($hash->{NUMUNITS} < 1) {
|
||||||
return "SISPM no SIMPM devices found.";
|
return "SISPM no SISPM devices found.";
|
||||||
}
|
}
|
||||||
|
|
||||||
$hash->{Timer} = 30;
|
$hash->{Timer} = 30;
|
||||||
@ -286,6 +308,7 @@ SISPM_Read($)
|
|||||||
my $currentusbid=0;
|
my $currentusbid=0;
|
||||||
my $renumbered=0;
|
my $renumbered=0;
|
||||||
my $newPMfound=0;
|
my $newPMfound=0;
|
||||||
|
my $tmpnr=-1;
|
||||||
|
|
||||||
($eof, @lines) = nonblockGetLinesSISPM($FH);
|
($eof, @lines) = nonblockGetLinesSISPM($FH);
|
||||||
|
|
||||||
@ -301,6 +324,7 @@ SISPM_Read($)
|
|||||||
if($eof != 1) {
|
if($eof != 1) {
|
||||||
foreach my $inputline ( @lines ) {
|
foreach my $inputline ( @lines ) {
|
||||||
$inputline =~ s/\s+$//;
|
$inputline =~ s/\s+$//;
|
||||||
|
Log 5, "SISPM_Read: read /$inputline/";
|
||||||
|
|
||||||
# wusel, 2010-01-16: Seems as if reading not always works as expected;
|
# wusel, 2010-01-16: Seems as if reading not always works as expected;
|
||||||
# throw away the whole readings if there's a NULL
|
# throw away the whole readings if there's a NULL
|
||||||
@ -351,7 +375,35 @@ SISPM_Read($)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($inputline =~ /^This device has a serial number of (.*)/) {
|
# New for SiS PM Control for Linux 3.1
|
||||||
|
if($inputline =~ /^Gembird #(\d+)$/) {
|
||||||
|
Log 5, "SISPM found SISPM device number $1 (sispmctl v3)";
|
||||||
|
$tmpnr=$1;
|
||||||
|
}
|
||||||
|
if($tmpnr >= 0 && $inputline =~ /^USB information: bus 001, device (\d+)/) {
|
||||||
|
Log 5, "SISPM found SISPM device number $tmpnr as USB $1";
|
||||||
|
if($tmpnr < $hash->{NUMUNITS}) {
|
||||||
|
if($hash->{UNITS}{$tmpnr}{USB}!=$1) {
|
||||||
|
Log 3, "SISPM: USB ids changed (unit $tmpnr is now USB $1 but was " . $hash->{UNITS}{$tmpnr}{USB} . "); will fix.";
|
||||||
|
$renumbered=1;
|
||||||
|
$hash->{FIXRENUMBER}="yes";
|
||||||
|
}
|
||||||
|
} else { # Something wonderful has happened, we have a new SIS PM!
|
||||||
|
Log 3, "SISPM: Wuuuhn! Found a new unit $tmpnr as USB $1 with sispmctl v3. Will assimilate it.";
|
||||||
|
$newPMfound=1;
|
||||||
|
$hash->{FIXNEW}="yes";
|
||||||
|
}
|
||||||
|
$currentdevice=$tmpnr;
|
||||||
|
$currentusbid=$1;
|
||||||
|
$currentserial="none";
|
||||||
|
if(defined($hash->{UNITS}{$currentdevice}{SERIAL})) {
|
||||||
|
$currentserial=$hash->{UNITS}{$currentdevice}{SERIAL};
|
||||||
|
}
|
||||||
|
$tmpnr=-1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if($inputline =~ /^This device has a serial number of (.*)/ ||
|
||||||
|
$inputline =~ /^serial number:\s+(.*)/) {
|
||||||
$currentserial=FixSISPMSerial($1);
|
$currentserial=FixSISPMSerial($1);
|
||||||
if($currentserial eq "00:00:00:00:00") {
|
if($currentserial eq "00:00:00:00:00") {
|
||||||
Log 3, "SISPM Whooopsie! Your serial nullified ($currentserial). Skipping ...";
|
Log 3, "SISPM Whooopsie! Your serial nullified ($currentserial). Skipping ...";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user