mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-05-04 22:19:38 +00:00
git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@5337 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
839eca5818
commit
c3711b502f
@ -76,7 +76,7 @@ use strict;
|
|||||||
use warnings;
|
use warnings;
|
||||||
sub Log($$);
|
sub Log($$);
|
||||||
|
|
||||||
my $owx_version="5.06";
|
my $owx_version="5.11";
|
||||||
#-- fixed raw channel name, flexible channel name
|
#-- fixed raw channel name, flexible channel name
|
||||||
my @owg_fixed = ("A","B","C","D");
|
my @owg_fixed = ("A","B","C","D");
|
||||||
my @owg_channel = ("A","B","C","D");
|
my @owg_channel = ("A","B","C","D");
|
||||||
@ -98,6 +98,7 @@ my %gets = (
|
|||||||
);
|
);
|
||||||
|
|
||||||
my %sets = (
|
my %sets = (
|
||||||
|
"initialize" => "",
|
||||||
"interval" => "",
|
"interval" => "",
|
||||||
"AAlarm" => "",
|
"AAlarm" => "",
|
||||||
"ALow" => "",
|
"ALow" => "",
|
||||||
@ -658,7 +659,7 @@ sub OWAD_Get($@) {
|
|||||||
$value .= "alarmed low, ";
|
$value .= "alarmed low, ";
|
||||||
}
|
}
|
||||||
if (!defined $hash->{owg_shigh}) {
|
if (!defined $hash->{owg_shigh}) {
|
||||||
$value .= "high aralm undefined";
|
$value .= "high alarm undefined";
|
||||||
} elsif( $hash->{owg_shigh}->[$i]==0 ) {
|
} elsif( $hash->{owg_shigh}->[$i]==0 ) {
|
||||||
$value .= "high alarm disabled";
|
$value .= "high alarm disabled";
|
||||||
} elsif( $hash->{owg_shigh}->[$i]==1 ) {
|
} elsif( $hash->{owg_shigh}->[$i]==1 ) {
|
||||||
@ -860,7 +861,13 @@ sub OWAD_Set($@) {
|
|||||||
my $name = $hash->{NAME};
|
my $name = $hash->{NAME};
|
||||||
my $model = $hash->{OW_MODEL};
|
my $model = $hash->{OW_MODEL};
|
||||||
|
|
||||||
#-- set new timer interval
|
#-- re-intialize
|
||||||
|
if($key eq "initialize") {
|
||||||
|
OWADInitializeDevice($hash);
|
||||||
|
return undef;
|
||||||
|
}
|
||||||
|
|
||||||
|
#-- set new timer interval
|
||||||
if($key eq "interval") {
|
if($key eq "interval") {
|
||||||
# check value
|
# check value
|
||||||
return "OWAD: Set with short interval, must be > 1"
|
return "OWAD: Set with short interval, must be > 1"
|
||||||
@ -1384,9 +1391,10 @@ sub OWXAD_GetPage($$$) {
|
|||||||
OWX_Reset($master);
|
OWX_Reset($master);
|
||||||
#-- reading 9 + 3 + 8 data bytes and 2 CRC bytes = 22 bytes
|
#-- reading 9 + 3 + 8 data bytes and 2 CRC bytes = 22 bytes
|
||||||
$res=OWX_Complex($master,$owx_dev,$select,10);
|
$res=OWX_Complex($master,$owx_dev,$select,10);
|
||||||
if( $res eq 0 ){
|
return "$owx_dev not accessible in reading page $page"
|
||||||
return "$owx_dev not accessible in reading $page page";
|
if( $res eq 0 );
|
||||||
}
|
return "$owx_dev has returned invalid data"
|
||||||
|
if( length($res)!=22);
|
||||||
#-- for processing we also need the 3 command bytes
|
#-- for processing we also need the 3 command bytes
|
||||||
OWXAD_BinValues($hash,"ds2450.get".$page,1,undef,$owx_dev,undef,$final,substr($res,9,13));
|
OWXAD_BinValues($hash,"ds2450.get".$page,1,undef,$owx_dev,undef,$final,substr($res,9,13));
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
#
|
#
|
||||||
# where <name> may be replaced by any name string
|
# where <name> may be replaced by any name string
|
||||||
#
|
#
|
||||||
# <model> is a 1-Wire device type DS2423 or DS2423emu. If omitted, we assume this to be an
|
# <model> is a 1-Wire device type DS2423,DS2423ene,wDS2423eold. If omitted, we assume this to be an
|
||||||
# DS2423 Counter/RAM
|
# DS2423 Counter/RAM
|
||||||
# <FAM_ID> is a 1-Wire family id, currently allowed value is 1D
|
# <FAM_ID> is a 1-Wire family id, currently allowed value is 1D
|
||||||
# <ROM_ID> is a 12 character (6 byte) 1-Wire ROM ID
|
# <ROM_ID> is a 12 character (6 byte) 1-Wire ROM ID
|
||||||
@ -35,7 +35,9 @@
|
|||||||
#
|
#
|
||||||
# set <name> interval => set query interval for measurement
|
# set <name> interval => set query interval for measurement
|
||||||
# set <name> memory <page> => 32 byte string into page 0..13
|
# set <name> memory <page> => 32 byte string into page 0..13
|
||||||
# set <name> midnight <channel> => todays starting value for counter
|
# set <name> midnight <channel> => todays starting value for counter
|
||||||
|
# set <name> counter <channel> => correct midnight value such that
|
||||||
|
# counter shows this value
|
||||||
#
|
#
|
||||||
# Additional attributes are defined in fhem.cfg, in some cases per channel, where <channel>=A,B
|
# Additional attributes are defined in fhem.cfg, in some cases per channel, where <channel>=A,B
|
||||||
#
|
#
|
||||||
@ -84,7 +86,7 @@ use strict;
|
|||||||
use warnings;
|
use warnings;
|
||||||
sub Log($$);
|
sub Log($$);
|
||||||
|
|
||||||
my $owx_version="5.09";
|
my $owx_version="5.11";
|
||||||
#-- fixed raw channel name, flexible channel name
|
#-- fixed raw channel name, flexible channel name
|
||||||
my @owg_fixed = ("A","B");
|
my @owg_fixed = ("A","B");
|
||||||
my @owg_channel = ("A","B");
|
my @owg_channel = ("A","B");
|
||||||
@ -106,7 +108,8 @@ my %gets = (
|
|||||||
my %sets = (
|
my %sets = (
|
||||||
"interval" => "",
|
"interval" => "",
|
||||||
"memory" => "",
|
"memory" => "",
|
||||||
"midnight" => ""
|
"midnight" => "",
|
||||||
|
"counter" => ""
|
||||||
);
|
);
|
||||||
|
|
||||||
my %updates = (
|
my %updates = (
|
||||||
@ -137,7 +140,7 @@ sub OWCOUNT_Initialize ($) {
|
|||||||
$hash->{SetFn} = "OWCOUNT_Set";
|
$hash->{SetFn} = "OWCOUNT_Set";
|
||||||
$hash->{AttrFn} = "OWCOUNT_Attr";
|
$hash->{AttrFn} = "OWCOUNT_Attr";
|
||||||
#-- see header for attributes
|
#-- see header for attributes
|
||||||
my $attlist = "IODev do_not_notify:0,1 showtime:0,1 model:DS2423,DS2423emu loglevel:0,1,2,3,4,5 LogM LogY ".
|
my $attlist = "IODev do_not_notify:0,1 showtime:0,1 model:DS2423,DS2423enew,DS2423eold loglevel:0,1,2,3,4,5 LogM LogY ".
|
||||||
"nomemory:1,0 interval ".
|
"nomemory:1,0 interval ".
|
||||||
$readingFnAttributes;
|
$readingFnAttributes;
|
||||||
for( my $i=0;$i<int(@owg_fixed);$i++ ){
|
for( my $i=0;$i<int(@owg_fixed);$i++ ){
|
||||||
@ -213,9 +216,12 @@ sub OWCOUNT_Define ($$) {
|
|||||||
if( $model eq "DS2423" ){
|
if( $model eq "DS2423" ){
|
||||||
$fam = "1D";
|
$fam = "1D";
|
||||||
CommandAttr (undef,"$name model DS2423");
|
CommandAttr (undef,"$name model DS2423");
|
||||||
}elsif( $model eq "DS2423emu" ){
|
}elsif( $model eq "DS2423enew" ){
|
||||||
$fam = "1D";
|
$fam = "1D";
|
||||||
CommandAttr (undef,"$name model DS2423emu");
|
CommandAttr (undef,"$name model DS2423enew");
|
||||||
|
}elsif( $model eq "DS2423eold" ){
|
||||||
|
$fam = "1D";
|
||||||
|
CommandAttr (undef,"$name model DS2423eold");
|
||||||
CommandAttr (undef,"$name nomemory 1");
|
CommandAttr (undef,"$name nomemory 1");
|
||||||
}else{
|
}else{
|
||||||
return "OWCOUNT: Wrong 1-Wire device model $model";
|
return "OWCOUNT: Wrong 1-Wire device model $model";
|
||||||
@ -676,34 +682,38 @@ sub OWCOUNT_Get($@) {
|
|||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#-- get memory page/counter according to interface type
|
#-- get memory page/counter according to interface type
|
||||||
my $interface= $hash->{IODev}->{TYPE};
|
my $interface= $hash->{IODev}->{TYPE};
|
||||||
|
|
||||||
#-- check syntax for getting memory page 0..13 or midnight A/B
|
#-- check syntax for getting memory page 0..13 or midnight A/B
|
||||||
my $nomemory = defined($attr{$name}{"nomemory"}) ? $attr{$name}{"nomemory"} : 0;
|
my $nomemory = defined($attr{$name}{"nomemory"}) ? $attr{$name}{"nomemory"} : 0;
|
||||||
if( ($reading eq "memory") || ($reading eq "midnight") ){
|
if( $reading eq "memory" ){
|
||||||
if( $reading eq "memory" ){
|
return "OWCOUNT: Memory usage disabled"
|
||||||
return "OWCOUNT: Memory usage disabled"
|
if( $nomemory==1 );
|
||||||
if( $nomemory==1 );
|
return "OWCOUNT: Get needs parameter when reading memory: <page>"
|
||||||
return "OWCOUNT: Get needs parameter when reading memory: <page>"
|
if( int(@a)<2 );
|
||||||
if( int(@a)<2 );
|
$page=int($a[2]);
|
||||||
$page=int($a[2]);
|
if( ($page<0) || ($page>13) ){
|
||||||
if( ($page<0) || ($page>13) ){
|
return "OWXCOUNT: Wrong memory page requested";
|
||||||
return "OWXCOUNT: Wrong memory page requested";
|
}
|
||||||
}
|
$ret = OWCOUNT_GetPage($hash,$page,1);
|
||||||
|
#-- when we have a return code, we have an error
|
||||||
|
if( $ret ){
|
||||||
|
return "OWCOUNT: Could not get values from device $name, reason: ".$ret;
|
||||||
}else{
|
}else{
|
||||||
return "OWCOUNT: get needs parameter when reading midnight: <channel>"
|
return "OWCOUNT: $name.$reading [$page] =>".$hash->{owg_str}->[$page];
|
||||||
if( int(@a)<2 );
|
}
|
||||||
#-- find out which channel we have
|
}
|
||||||
if( ($a[2] eq $owg_channel[0]) || ($a[2] eq "A") ){
|
if( $reading eq "midnight" ){
|
||||||
$page=14;
|
return "OWCOUNT: get needs parameter when reading midnight: <channel>"
|
||||||
}elsif( ($a[2] eq $owg_channel[1]) || ($a[2] eq "B") ){
|
if( int(@a)<3 );
|
||||||
$page=15;
|
#-- find out which channel we have
|
||||||
} else {
|
if( ($a[2] eq $owg_channel[0]) || ($a[2] eq "A") ){
|
||||||
return "OWCOUNT: Invalid midnight counter address, must be A, B or defined channel name"
|
$page=14;
|
||||||
}
|
}elsif( ($a[2] eq $owg_channel[1]) || ($a[2] eq "B") ){
|
||||||
|
$page=15;
|
||||||
|
} else {
|
||||||
|
return "OWCOUNT: Invalid midnight counter address, must be A, B or defined channel name"
|
||||||
}
|
}
|
||||||
$ret = OWCOUNT_GetPage($hash,$page,1);
|
$ret = OWCOUNT_GetPage($hash,$page,1);
|
||||||
#-- when we have a return code, we have an error
|
#-- when we have a return code, we have an error
|
||||||
@ -791,28 +801,28 @@ sub OWCOUNT_GetPage ($$$) {
|
|||||||
}else{
|
}else{
|
||||||
return "OWCOUNT: GetPage with wrong IODev type $interface";
|
return "OWCOUNT: GetPage with wrong IODev type $interface";
|
||||||
}
|
}
|
||||||
|
|
||||||
#-- process results
|
#-- process results
|
||||||
if( defined($ret) ){
|
if( defined($ret) ){
|
||||||
return "OWCOUNT: Could not get values from device $name, reason: ".$ret;
|
return "OWCOUNT: Could not get values from device $name, reason: ".$ret;
|
||||||
} else {
|
|
||||||
return undef
|
|
||||||
if ($nomemory==0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#-- when we are here, we need to read the files
|
if( ($page==14)||($page==15) ){
|
||||||
my $strval = OWCOUNT_recall($hash,"OWCOUNT_".$name."_".$page.".dat");
|
#-- when we are here, we need to read the files
|
||||||
|
my $strval = OWCOUNT_recall($hash,"OWCOUNT_".$name."_".$page.".dat");
|
||||||
|
|
||||||
#-- midnight value
|
#-- midnight value
|
||||||
#-- new format
|
#-- new format
|
||||||
if ($strval =~ /^\d\d\d\d-\d\d-\d\d.*/){
|
if ($strval =~ /^\d\d\d\d-\d\d-\d\d.*/){
|
||||||
my @data=split(' ',$strval);
|
my @data=split(' ',$strval);
|
||||||
$strval = $data[2];
|
$strval = $data[2];
|
||||||
|
}
|
||||||
|
#-- parse float from midnight
|
||||||
|
$strval =~ s/[^\d\.]+//g;
|
||||||
|
$strval = 0.0 if(!defined($strval) or $strval !~ /^\d+\.\d*$/);
|
||||||
|
$strval = int($strval*100)/100;
|
||||||
|
$hash->{owg_midnight}->[$page-14] = $strval;
|
||||||
}
|
}
|
||||||
#-- parse float from midnight
|
|
||||||
$strval =~ s/[^\d\.]+//g;
|
|
||||||
$strval = 0.0 if(!defined($strval) or $strval !~ /^\d+\.\d*$/);
|
|
||||||
$strval = int($strval*100)/100;
|
|
||||||
$hash->{owg_midnight}->[$page-14] = $strval;
|
|
||||||
OWCOUNT_FormatValues($hash)
|
OWCOUNT_FormatValues($hash)
|
||||||
if($oldfinal==1);
|
if($oldfinal==1);
|
||||||
|
|
||||||
@ -889,7 +899,6 @@ sub OWCOUNT_GetMonth($) {
|
|||||||
return "cannot open logfile of LogM";
|
return "cannot open logfile of LogM";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#-- sum and average
|
#-- sum and average
|
||||||
for (my $i=0;$i<int(@owg_fixed);$i++){
|
for (my $i=0;$i<int(@owg_fixed);$i++){
|
||||||
$total = 0.0;
|
$total = 0.0;
|
||||||
@ -1089,10 +1098,31 @@ sub OWCOUNT_InitializeDevice($) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#-- testing if it is the emulator
|
#-- testing if it is the emulator
|
||||||
#-- The model may be DS2423 or DS2423emu. Some weird people are violating 1-Wire integrity by using the
|
#-- The model may be DS2423, DS2423enew or DS2423eold. Some weird people are violating 1-Wire integrity by using the
|
||||||
# the same family ID although the DS2423emu does not fully support the DS2423 commands.
|
# the same family ID although the DS2423emu does not fully support the DS2423 commands.
|
||||||
# Model attribute will be modified now after checking for memory
|
# Model attribute will be modified now after checking for memory
|
||||||
#-- OWX interface
|
#-- OWX interface
|
||||||
|
if( $interface eq "OWX" ){
|
||||||
|
$ret = OWXCOUNT_GetPage($hash,14,0);
|
||||||
|
$olddata = $hash->{owg_str}->[14];
|
||||||
|
$ret = OWXCOUNT_SetPage($hash,14,$newdata);
|
||||||
|
$ret = OWXCOUNT_GetPage($hash,14,0);
|
||||||
|
$ret = OWXCOUNT_SetPage($hash,14,$olddata);
|
||||||
|
|
||||||
|
#-- OWFS interface
|
||||||
|
}elsif( $interface eq "OWServer" ){
|
||||||
|
$ret = OWXCOUNT_GetPage($hash,14,0);
|
||||||
|
$olddata = $hash->{owg_str}->[14];
|
||||||
|
$ret = OWFSCOUNT_SetPage($hash,14,$newdata);
|
||||||
|
$ret = OWFSCOUNT_GetPage($hash,14,0);
|
||||||
|
$ret = OWFSCOUNT_SetPage($hash,14,$olddata);
|
||||||
|
#-- Unknown interface
|
||||||
|
}else{
|
||||||
|
return "OWCOUNT: InitializeDevice with wrong IODev type $interface";
|
||||||
|
}
|
||||||
|
#Log 1,"FIRST CHECK: written $newdata, read ".substr($hash->{owg_str}->[14],0,length($newdata));
|
||||||
|
my $nomid = ( substr($hash->{owg_str}->[14],0,length($newdata)) ne $newdata );
|
||||||
|
#-- OWX interface
|
||||||
if( $interface eq "OWX" ){
|
if( $interface eq "OWX" ){
|
||||||
$ret = OWXCOUNT_GetPage($hash,0,0);
|
$ret = OWXCOUNT_GetPage($hash,0,0);
|
||||||
$olddata = $hash->{owg_str}->[0];
|
$olddata = $hash->{owg_str}->[0];
|
||||||
@ -1111,10 +1141,16 @@ sub OWCOUNT_InitializeDevice($) {
|
|||||||
}else{
|
}else{
|
||||||
return "OWCOUNT: InitializeDevice with wrong IODev type $interface";
|
return "OWCOUNT: InitializeDevice with wrong IODev type $interface";
|
||||||
}
|
}
|
||||||
|
#Log 1,"SECOND CHECK: written $newdata, read ".substr($hash->{owg_str}->[0],0,length($newdata));
|
||||||
|
my $nomem = ( substr($hash->{owg_str}->[0],0,length($newdata)) ne $newdata );
|
||||||
#-- Here we test if writing the memory is ok.
|
#-- Here we test if writing the memory is ok.
|
||||||
if( substr($hash->{owg_str}->[0],0,length($newdata)) ne $newdata ){
|
if( !$nomid && $nomem ){
|
||||||
Log 1,"OWCOUNT: model attribute of $name set to DS2423emu because no memory found";
|
Log 1,"OWCOUNT: model attribute of $name set to DS2423enew";
|
||||||
CommandAttr (undef,"$name model DS2423emu");
|
CommandAttr (undef,"$name model DS2423enew");
|
||||||
|
CommandAttr (undef,"$name nomemory 0");
|
||||||
|
} elsif( $nomid && $nomem ){
|
||||||
|
Log 1,"OWCOUNT: model attribute of $name set to DS2423eold because no memory found";
|
||||||
|
CommandAttr (undef,"$name model DS2423eold");
|
||||||
CommandAttr (undef,"$name nomemory 1");
|
CommandAttr (undef,"$name nomemory 1");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1179,7 +1215,7 @@ sub OWCOUNT_Set($@) {
|
|||||||
#-- set memory page/counter according to interface type
|
#-- set memory page/counter according to interface type
|
||||||
my $interface= $hash->{IODev}->{TYPE};
|
my $interface= $hash->{IODev}->{TYPE};
|
||||||
|
|
||||||
#-- check syntax for setting memory page 0..13 or midnight A/B
|
#-- check syntax for setting memory page 0..13
|
||||||
my $nomemory = defined($attr{$name}{"nomemory"}) ? $attr{$name}{"nomemory"} : 0;
|
my $nomemory = defined($attr{$name}{"nomemory"}) ? $attr{$name}{"nomemory"} : 0;
|
||||||
if( $key eq "memory" ){
|
if( $key eq "memory" ){
|
||||||
return "OWCOUNT: Memory usage disabled"
|
return "OWCOUNT: Memory usage disabled"
|
||||||
@ -1204,8 +1240,10 @@ sub OWCOUNT_Set($@) {
|
|||||||
}
|
}
|
||||||
$ret = OWCOUNT_SetPage($hash,$page,$data);
|
$ret = OWCOUNT_SetPage($hash,$page,$data);
|
||||||
}
|
}
|
||||||
if( $key eq "midnight" ){
|
|
||||||
return "OWCOUNT: Set needs parameter when writing midnight: <channel>"
|
#-- other commands are per channel
|
||||||
|
if( ($key eq "midnight") || ($key eq "counter" )){
|
||||||
|
return "OWCOUNT: Set $key needs parameter: <channel>"
|
||||||
if( int(@a)<2 );
|
if( int(@a)<2 );
|
||||||
#-- find out which channel we have
|
#-- find out which channel we have
|
||||||
if( ($a[2] eq $owg_channel[0]) || ($a[2] eq "A") ){
|
if( ($a[2] eq $owg_channel[0]) || ($a[2] eq "A") ){
|
||||||
@ -1213,12 +1251,34 @@ sub OWCOUNT_Set($@) {
|
|||||||
}elsif( ($a[2] eq $owg_channel[1]) || ($a[2] eq "B") ){
|
}elsif( ($a[2] eq $owg_channel[1]) || ($a[2] eq "B") ){
|
||||||
$page=15;
|
$page=15;
|
||||||
} else {
|
} else {
|
||||||
return "OWCOUNT: Invalid midnight counter address, must be A, B or defined channel name"
|
return "OWCOUNT: Invalid counter address, must be A, B or defined channel name"
|
||||||
}
|
}
|
||||||
|
#-- mode normal or daily
|
||||||
|
my $daily = 0;
|
||||||
|
if( defined($attr{$name}{$owg_fixed[$page-14]."Mode"} )){
|
||||||
|
if( $attr{$name}{$owg_fixed[$page-14]."Mode"} eq "daily"){
|
||||||
|
$daily = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return "OWCOUNT: Set $key for channel $a[2] not possible, is not in daily mode"
|
||||||
|
if( $daily==0 );
|
||||||
|
|
||||||
my ($sec, $min, $hour, $day, $month, $year, $wday,$yday,$isdst) = localtime(time);
|
my ($sec, $min, $hour, $day, $month, $year, $wday,$yday,$isdst) = localtime(time);
|
||||||
$data = sprintf("%4d-%02d-%02d midnight %7.2f",
|
|
||||||
|
if( $key eq "midnight" ){
|
||||||
|
$data = sprintf("%4d-%02d-%02d midnight %7.2f",
|
||||||
$year+1900,$month+1,$day,$a[3]);
|
$year+1900,$month+1,$day,$a[3]);
|
||||||
$ret = OWCOUNT_SetPage($hash,$page,$data);
|
$ret = OWCOUNT_SetPage($hash,$page,$data);
|
||||||
|
}
|
||||||
|
#--
|
||||||
|
if( $key eq "counter" ){
|
||||||
|
my $midnew=($hash->{owg_val}->[$page-14] + $hash->{READINGS}{$owg_channel[$page-14]}{OFFSET})*
|
||||||
|
$hash->{READINGS}{$owg_channel[$page-14]}{FACTOR} - $a[3];
|
||||||
|
$data = sprintf("%4d-%02d-%02d midnight %7.2f",
|
||||||
|
$year+1900,$month+1,$day,$midnew);
|
||||||
|
#Log 1,"OLD MIDNIGHT ".$hash->{owg_midnight}->[$page-14]." NEW $midnew";
|
||||||
|
$ret = OWCOUNT_SetPage($hash,$page,$data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#-- process results - we have to reread the device
|
#-- process results - we have to reread the device
|
||||||
if( defined($ret) && ($ret ne "") ){
|
if( defined($ret) && ($ret ne "") ){
|
||||||
@ -1390,6 +1450,12 @@ sub OWFSCOUNT_GetPage($$$) {
|
|||||||
|
|
||||||
$hash->{owg_val}->[0] = $vval;
|
$hash->{owg_val}->[0] = $vval;
|
||||||
$hash->{owg_str}->[14] = $strval;
|
$hash->{owg_str}->[14] = $strval;
|
||||||
|
#-- midnight value
|
||||||
|
#-- new format
|
||||||
|
if ($strval =~ /^\d\d\d\d-\d\d-\d\d.*/){
|
||||||
|
my @data=split(' ',$strval);
|
||||||
|
$strval = $data[2];
|
||||||
|
}
|
||||||
#-- parse float from midnight
|
#-- parse float from midnight
|
||||||
$strval =~ s/[^\d\.]+//g;
|
$strval =~ s/[^\d\.]+//g;
|
||||||
$strval = 0.0 if(!defined($strval) or $strval !~ /^\d+\.?\d*$/);
|
$strval = 0.0 if(!defined($strval) or $strval !~ /^\d+\.?\d*$/);
|
||||||
@ -1407,6 +1473,12 @@ sub OWFSCOUNT_GetPage($$$) {
|
|||||||
$hash->{owg_val}->[1] = $vval;
|
$hash->{owg_val}->[1] = $vval;
|
||||||
$hash->{owg_str}->[15] = $strval;
|
$hash->{owg_str}->[15] = $strval;
|
||||||
|
|
||||||
|
#-- midnight value
|
||||||
|
#-- new format
|
||||||
|
if ($strval =~ /^\d\d\d\d-\d\d-\d\d.*/){
|
||||||
|
my @data=split(' ',$strval);
|
||||||
|
$strval = $data[2];
|
||||||
|
}
|
||||||
#-- parse float from midnight
|
#-- parse float from midnight
|
||||||
$strval =~ s/[^\d\.]+//g;
|
$strval =~ s/[^\d\.]+//g;
|
||||||
$strval = 0.0 if(!defined($strval) or $strval !~ /^\d+\.\d*$/);
|
$strval = 0.0 if(!defined($strval) or $strval !~ /^\d+\.\d*$/);
|
||||||
@ -1451,6 +1523,21 @@ sub OWFSCOUNT_SetPage($$$) {
|
|||||||
if( ($page<0) || ($page>15) ){
|
if( ($page<0) || ($page>15) ){
|
||||||
return "wrong memory page write attempt";
|
return "wrong memory page write attempt";
|
||||||
}
|
}
|
||||||
|
#=============== midnight value =====================================
|
||||||
|
if( ($page==14) || ($page==15) ){
|
||||||
|
my $strval=$data;
|
||||||
|
#-- midnight value
|
||||||
|
#-- new format
|
||||||
|
if ($strval =~ /^\d\d\d\d-\d\d-\d\d.*/){
|
||||||
|
my @datan=split(' ',$strval);
|
||||||
|
$strval = $datan[2];
|
||||||
|
}
|
||||||
|
#-- parse float from midnight
|
||||||
|
$strval =~ s/[^\d\.]+//g;
|
||||||
|
$strval = 0.0 if(!defined($strval) or $strval !~ /^\d+\.\d*$/);
|
||||||
|
$strval = int($strval*100)/100;
|
||||||
|
$hash->{owg_midnight}->[$page-14] = $strval;
|
||||||
|
}
|
||||||
OWServer_Write($master, "/$owx_add/pages/page.".$page,$data );
|
OWServer_Write($master, "/$owx_add/pages/page.".$page,$data );
|
||||||
return undef
|
return undef
|
||||||
}
|
}
|
||||||
@ -1487,15 +1574,25 @@ sub OWXCOUNT_BinValues($$$$$$$$) {
|
|||||||
if( int(@data) < 45);
|
if( int(@data) < 45);
|
||||||
#return "invalid data"
|
#return "invalid data"
|
||||||
# if (ord($data[17])<=0);
|
# if (ord($data[17])<=0);
|
||||||
Log 1,"invalid CRC"
|
Log 1,"invalid CRC, ".ord($data[43])." ".ord($data[44])
|
||||||
if (OWX_CRC16(substr($res,0,43),$data[43],$data[44]) == 0);
|
if (OWX_CRC16(substr($res,0,43),$data[43],$data[44]) == 0);
|
||||||
|
|
||||||
#-- first 3 command, next 32 are memory
|
#-- first 3 command, next 32 are memory
|
||||||
|
#my $res2 = "OWCOUNT FIRST 10 BYTES for device $owx_dev ARE ";
|
||||||
|
#for($i=0;$i<10;$i++){
|
||||||
|
# $j=int(ord(substr($res,$i,1))/16);
|
||||||
|
# $k=ord(substr($res,$i,1))%16;
|
||||||
|
# $res2.=sprintf "0x%1x%1x ",$j,$k;
|
||||||
|
#}
|
||||||
|
#main::Log(1, $res2);
|
||||||
|
|
||||||
|
#--
|
||||||
my $nomemory = defined($attr{$name}{"nomemory"}) ? $attr{$name}{"nomemory"} : 0;
|
my $nomemory = defined($attr{$name}{"nomemory"}) ? $attr{$name}{"nomemory"} : 0;
|
||||||
if( $nomemory==0 ){
|
if( $nomemory==0 ){
|
||||||
#-- memory part, treated as string
|
#-- memory part, treated as string
|
||||||
$strval=substr($res,3,32);
|
$strval=substr($res,3,32);
|
||||||
$hash->{owg_str}->[$page]=$strval;
|
$hash->{owg_str}->[$page]=$strval;
|
||||||
|
#Log 1," retrieved on device $owx_dev for page $page STRING $strval";
|
||||||
}
|
}
|
||||||
#-- counter part
|
#-- counter part
|
||||||
if( ($page == 14) || ($page == 15) ){
|
if( ($page == 14) || ($page == 15) ){
|
||||||
@ -1596,8 +1693,11 @@ sub OWXCOUNT_GetPage($$$) {
|
|||||||
#-- reset the bus (needed to stop receiving data ?)
|
#-- reset the bus (needed to stop receiving data ?)
|
||||||
OWX_Reset($master);
|
OWX_Reset($master);
|
||||||
#-- for processing we need 45 bytes
|
#-- for processing we need 45 bytes
|
||||||
OWXCOUNT_BinValues($hash,$page,undef,undef,$owx_dev,undef,$final,substr($res,9))
|
return "$owx_dev not accessible in reading"
|
||||||
if( length($res)==54 );
|
if( $res eq 0 );
|
||||||
|
return "$owx_dev has returned invalid data"
|
||||||
|
if( length($res)!=54);
|
||||||
|
OWXCOUNT_BinValues($hash,$page,undef,undef,$owx_dev,undef,$final,substr($res,9));
|
||||||
}
|
}
|
||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
@ -1617,6 +1717,8 @@ sub OWXCOUNT_SetPage($$$) {
|
|||||||
|
|
||||||
my ($select, $res, $res2, $res3);
|
my ($select, $res, $res2, $res3);
|
||||||
|
|
||||||
|
my ($i,$j,$k);
|
||||||
|
|
||||||
#-- ID of the device, hash of the busmaster
|
#-- ID of the device, hash of the busmaster
|
||||||
my $owx_dev = $hash->{ROM_ID};
|
my $owx_dev = $hash->{ROM_ID};
|
||||||
my $master = $hash->{IODev};
|
my $master = $hash->{IODev};
|
||||||
@ -1625,19 +1727,44 @@ sub OWXCOUNT_SetPage($$$) {
|
|||||||
if( ($page<0) || ($page>15) ){
|
if( ($page<0) || ($page>15) ){
|
||||||
return "wrong memory page write attempt";
|
return "wrong memory page write attempt";
|
||||||
}
|
}
|
||||||
|
#=============== midnight value =====================================
|
||||||
|
if( ($page==14) || ($page==15) ){
|
||||||
|
my $strval=$data;
|
||||||
|
#-- midnight value
|
||||||
|
#-- new format
|
||||||
|
if ($strval =~ /^\d\d\d\d-\d\d-\d\d.*/){
|
||||||
|
my @datan=split(' ',$strval);
|
||||||
|
$strval = $datan[2];
|
||||||
|
}
|
||||||
|
#-- parse float from midnight
|
||||||
|
$strval =~ s/[^\d\.]+//g;
|
||||||
|
$strval = 0.0 if(!defined($strval) or $strval !~ /^\d+\.\d*$/);
|
||||||
|
$strval = int($strval*100)/100;
|
||||||
|
$hash->{owg_midnight}->[$page-14] = $strval;
|
||||||
|
}
|
||||||
#=============== set memory =========================================
|
#=============== set memory =========================================
|
||||||
#-- issue the match ROM command \x55 and the write scratchpad command
|
#-- issue the match ROM command \x55 and the write scratchpad command
|
||||||
# \x0F TA1 TA2 and the read scratchpad command reading 3 data bytes
|
# \x0F TA1 TA2 followed by the data
|
||||||
my $ta2 = ($page*32) >> 8;
|
my $ta2 = ($page*32) >> 8;
|
||||||
my $ta1 = ($page*32) & 255;
|
my $ta1 = ($page*32) & 255;
|
||||||
#Log 1, "OWXCOUNT: setting page Nr. $ta2 $ta1";
|
#Log 1, "OWXCOUNT: setting page Nr. $ta2 $ta1 $data";
|
||||||
$select=sprintf("\x0F%c%c",$ta1,$ta2).$data;
|
$select=sprintf("\x0F%c%c",$ta1,$ta2).$data;
|
||||||
|
|
||||||
|
#-- first command, next 2 are address, then data
|
||||||
|
#$res2 = "OWCOUNT SET PAGE 1 device $owx_dev ";
|
||||||
|
#for($i=0;$i<10;$i++){
|
||||||
|
# $j=int(ord(substr($select,$i,1))/16);
|
||||||
|
# $k=ord(substr($select,$i,1))%16;
|
||||||
|
# $res2.=sprintf "0x%1x%1x ",$j,$k;
|
||||||
|
#}
|
||||||
|
#main::Log(1, $res2);
|
||||||
|
|
||||||
#-- asynchronous mode
|
#-- asynchronous mode
|
||||||
if( $hash->{ASYNC} ){
|
if( $hash->{ASYNC} ){
|
||||||
if (OWX_Execute( $master, "setpage", 1, $owx_dev, $select, 0, undef )) {
|
if (OWX_Execute( $master, "setpage", 1, $owx_dev, $select, 0, undef )) {
|
||||||
return undef;
|
return undef;
|
||||||
} else {
|
} else {
|
||||||
return "device $owx_dev not accessible for writing";
|
return "device $owx_dev not accessible in writing scratchpad";
|
||||||
}
|
}
|
||||||
#-- synchronous mode
|
#-- synchronous mode
|
||||||
} else {
|
} else {
|
||||||
@ -1649,34 +1776,53 @@ sub OWXCOUNT_SetPage($$$) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#-- issue the match ROM command \x55 and the read scratchpad command
|
#-- issue the match ROM command \x55 and the read scratchpad command
|
||||||
# \xAA
|
# \xAA, receiving 2 address bytes, 1 status byte and scratchpad content
|
||||||
#-- asynchronous mode
|
#-- asynchronous mode
|
||||||
if( $hash->{ASYNC} ){
|
if( $hash->{ASYNC} ){
|
||||||
if (OWX_Execute( $master, "setpage", 1, $owx_dev, "\xAA", 0, undef )) {
|
if (OWX_Execute( $master, "setpage", 1, $owx_dev, "\xAA", 0, undef )) {
|
||||||
return undef;
|
return undef;
|
||||||
} else {
|
} else {
|
||||||
return "device $owx_dev not accessible for writing";
|
return "device $owx_dev not accessible in reading scratchpad";
|
||||||
}
|
}
|
||||||
#-- synchronous mode
|
#-- synchronous mode
|
||||||
} else {
|
} else {
|
||||||
#-- reset the bus
|
#-- reset the bus
|
||||||
OWX_Reset($master);
|
OWX_Reset($master);
|
||||||
#-- reading 9 + 4 + 16 bytes = 28 bytes
|
#-- reading 9 + 3 + up to 32 bytes
|
||||||
# TODO: sometimes much less than 28
|
# TODO: sometimes much less than 28
|
||||||
$res=OWX_Complex($master,$owx_dev,"\xAA",28);
|
$res=OWX_Complex($master,$owx_dev,"\xAA",28);
|
||||||
if( length($res) < 13 ){
|
if( length($res) < 13 ){
|
||||||
return "device $owx_dev not accessible in reading scratchpad";
|
return "device $owx_dev not accessible in reading scratchpad";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#-- first 1 command, next 2 are address, then data
|
||||||
|
#$res3 = substr($res,9,10);
|
||||||
|
#$res2 = "OWCOUNT SET PAGE 2 device $owx_dev ";
|
||||||
|
#for($i=0;$i<10;$i++){
|
||||||
|
# $j=int(ord(substr($res3,$i,1))/16);
|
||||||
|
# $k=ord(substr($res3,$i,1))%16;
|
||||||
|
# $res2.=sprintf "0x%1x%1x ",$j,$k;
|
||||||
|
#}
|
||||||
|
#main::Log(1, $res2);
|
||||||
}
|
}
|
||||||
#-- issue the match ROM command \x55 and the copy scratchpad command
|
#-- issue the match ROM command \x55 and the copy scratchpad command
|
||||||
# \x5A followed by 3 byte authentication code
|
# \x5A followed by 3 byte authentication code obtained in previous read
|
||||||
$select="\x5A".substr($res,10,3);
|
$select="\x5A".substr($res,10,3);
|
||||||
#-- asynchronous mode
|
#-- first command, next 2 are address, then data
|
||||||
|
#$res2 = "OWCOUNT SET PAGE 3 device $owx_dev ";
|
||||||
|
#for($i=0;$i<10;$i++){
|
||||||
|
# $j=int(ord(substr($select,$i,1))/16);
|
||||||
|
# $k=ord(substr($select,$i,1))%16;
|
||||||
|
# $res2.=sprintf "0x%1x%1x ",$j,$k;
|
||||||
|
#}
|
||||||
|
#main::Log(1, $res2);
|
||||||
|
#-- asynchronous mode
|
||||||
if( $hash->{ASYNC} ){
|
if( $hash->{ASYNC} ){
|
||||||
|
# THIS IS WRONG !!
|
||||||
if (OWX_Execute( $master, "setpage", 1, $owx_dev, "\xAA", 0, undef )) {
|
if (OWX_Execute( $master, "setpage", 1, $owx_dev, "\xAA", 0, undef )) {
|
||||||
return undef;
|
return undef;
|
||||||
} else {
|
} else {
|
||||||
return "device $owx_dev not accessible for writing";
|
return "device $owx_dev not accessible for copying scratchpad";
|
||||||
}
|
}
|
||||||
#-- synchronous mode
|
#-- synchronous mode
|
||||||
} else {
|
} else {
|
||||||
@ -1686,7 +1832,7 @@ sub OWXCOUNT_SetPage($$$) {
|
|||||||
|
|
||||||
#-- process results
|
#-- process results
|
||||||
if( $res eq 0 ){
|
if( $res eq 0 ){
|
||||||
return "device $owx_dev not accessible for writing";
|
return "device $owx_dev not accessible for copying scratchpad";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return undef;
|
return undef;
|
||||||
@ -1729,7 +1875,8 @@ sub OWXCOUNT_SetPage($$$) {
|
|||||||
id), currently the following values are permitted: <ul>
|
id), currently the following values are permitted: <ul>
|
||||||
<li>model DS2423 with family id 1D (default if the model parameter is
|
<li>model DS2423 with family id 1D (default if the model parameter is
|
||||||
omitted)</li>
|
omitted)</li>
|
||||||
<li>model DS2423emu with family id 1D - works like DS2423 except that the internal memory is not used</li>
|
<li>model DS2423enew with family id 1D - emulator, works like DS2423</li>
|
||||||
|
<li>model DS2423eold with family id 1D - emulator, works like DS2423 except that the internal memory is not present</li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
@ -1755,9 +1902,13 @@ sub OWXCOUNT_SetPage($$$) {
|
|||||||
<code>set <name> memory <page> <string></code></a><br />Write 32 bytes to
|
<code>set <name> memory <page> <string></code></a><br />Write 32 bytes to
|
||||||
memory page 0..13 </li>
|
memory page 0..13 </li>
|
||||||
<li><a name="owcount_midnight">
|
<li><a name="owcount_midnight">
|
||||||
<code>set <name> midnight <channel-name> <int></code></a><br />Write the
|
<code>set <name> midnight <channel-name> <val></code></a><br />Write the
|
||||||
day's starting value for counter <channel> (A, B or named channel, see
|
day's starting value for counter <channel> (A, B or named channel, see
|
||||||
below)</li>
|
below)</li>
|
||||||
|
<li><a name="owcount_counter">
|
||||||
|
<code>set <name> counter <channel-name> <val></code></a><br />Correct the midnight
|
||||||
|
value such that counter <channel> (A, B or named channel, see
|
||||||
|
below) displays value <val></li>
|
||||||
</ul>
|
</ul>
|
||||||
<br />
|
<br />
|
||||||
<a name="OWCOUNTget"></a>
|
<a name="OWCOUNTget"></a>
|
||||||
|
@ -49,11 +49,13 @@
|
|||||||
package main;
|
package main;
|
||||||
|
|
||||||
use vars qw{%attr %defs %modules $readingFnAttributes $init_done};
|
use vars qw{%attr %defs %modules $readingFnAttributes $init_done};
|
||||||
|
use Time::HiRes qw(usleep ualarm gettimeofday tv_interval);
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
sub Log($$);
|
sub Log($$);
|
||||||
|
|
||||||
my $owx_version="5.06";
|
my $owx_version="5.11";
|
||||||
#-- declare variables
|
#-- declare variables
|
||||||
my %gets = (
|
my %gets = (
|
||||||
"present" => "",
|
"present" => "",
|
||||||
@ -134,6 +136,9 @@ sub OWID_Define ($$) {
|
|||||||
if( $fam eq "01" ){
|
if( $fam eq "01" ){
|
||||||
$model = "DS2401";
|
$model = "DS2401";
|
||||||
CommandAttr (undef,"$name model DS2401");
|
CommandAttr (undef,"$name model DS2401");
|
||||||
|
}elsif( $fam eq "09" ){
|
||||||
|
$model = "DS2502";
|
||||||
|
CommandAttr (undef,"$name model DS2502");
|
||||||
}else{
|
}else{
|
||||||
$model = "unknown";
|
$model = "unknown";
|
||||||
CommandAttr (undef,"$name model unknown");
|
CommandAttr (undef,"$name model unknown");
|
||||||
@ -148,6 +153,9 @@ sub OWID_Define ($$) {
|
|||||||
if( $fam eq "01" ){
|
if( $fam eq "01" ){
|
||||||
$model = "DS2401";
|
$model = "DS2401";
|
||||||
CommandAttr (undef,"$name model DS2401");
|
CommandAttr (undef,"$name model DS2401");
|
||||||
|
}elsif( $fam eq "09" ){
|
||||||
|
$model = "DS2502";
|
||||||
|
CommandAttr (undef,"$name model DS2502");
|
||||||
}else{
|
}else{
|
||||||
$model = "unknown";
|
$model = "unknown";
|
||||||
CommandAttr (undef,"$name model unknown");
|
CommandAttr (undef,"$name model unknown");
|
||||||
@ -157,6 +165,9 @@ sub OWID_Define ($$) {
|
|||||||
if( $model eq "DS2401" ){
|
if( $model eq "DS2401" ){
|
||||||
$fam = "01";
|
$fam = "01";
|
||||||
CommandAttr (undef,"$name model DS2401");
|
CommandAttr (undef,"$name model DS2401");
|
||||||
|
}elsif( $model eq "DS2502" ){
|
||||||
|
$fam = "09";
|
||||||
|
CommandAttr (undef,"$name model DS2502");
|
||||||
}else{
|
}else{
|
||||||
return "OWID: Unknown 1-Wire device model $model";
|
return "OWID: Unknown 1-Wire device model $model";
|
||||||
}
|
}
|
||||||
@ -306,7 +317,7 @@ sub OWID_GetValues($) {
|
|||||||
my $hash = shift;
|
my $hash = shift;
|
||||||
|
|
||||||
my $name = $hash->{NAME};
|
my $name = $hash->{NAME};
|
||||||
my $value = "";
|
my $value = 0;
|
||||||
my $ret = "";
|
my $ret = "";
|
||||||
my $offset;
|
my $offset;
|
||||||
my $factor;
|
my $factor;
|
||||||
@ -317,7 +328,18 @@ sub OWID_GetValues($) {
|
|||||||
|
|
||||||
#-- hash of the busmaster
|
#-- hash of the busmaster
|
||||||
my $master = $hash->{IODev};
|
my $master = $hash->{IODev};
|
||||||
$value = OWX_Verify($master,$hash->{ROM_ID});
|
|
||||||
|
#-- measure elapsed time
|
||||||
|
my $t0 = [gettimeofday];
|
||||||
|
|
||||||
|
$value = OWX_Verify($master,$hash->{ROM_ID});
|
||||||
|
|
||||||
|
#my $thr = threads->create('OWX_Verify', $master, $hash->{ROM_ID});
|
||||||
|
#$thr->detach();
|
||||||
|
|
||||||
|
my $t1 = [gettimeofday];
|
||||||
|
my $t0_t1 = tv_interval $t0, $t1;
|
||||||
|
#Log 1,"====> Time for verify = $t0_t1";
|
||||||
|
|
||||||
#-- generate an event only if presence has changed
|
#-- generate an event only if presence has changed
|
||||||
if( $value == 0 ){
|
if( $value == 0 ){
|
||||||
|
@ -70,7 +70,7 @@ use strict;
|
|||||||
use warnings;
|
use warnings;
|
||||||
sub Log($$);
|
sub Log($$);
|
||||||
|
|
||||||
my $owx_version="5.06";
|
my $owx_version="5.11";
|
||||||
#-- flexible channel name
|
#-- flexible channel name
|
||||||
my $owg_channel;
|
my $owg_channel;
|
||||||
|
|
||||||
@ -913,9 +913,10 @@ sub OWXMULTI_GetValues($$) {
|
|||||||
OWX_Reset($master);
|
OWX_Reset($master);
|
||||||
$res=OWX_Complex($master,$owx_dev,"\xBE\x00",9);
|
$res=OWX_Complex($master,$owx_dev,"\xBE\x00",9);
|
||||||
#Log 1,"OWXMULTI: data length from reading device is ".length($res)." bytes";
|
#Log 1,"OWXMULTI: data length from reading device is ".length($res)." bytes";
|
||||||
if( $res eq 0 ){
|
return "$owx_dev not accessible in 2nd step"
|
||||||
return "$owx_dev not accessible in 2nd step";
|
if( $res eq 0 );
|
||||||
}
|
return "$owx_dev has returned invalid data"
|
||||||
|
if( length($res)!=20);
|
||||||
OWXMULTI_BinValues($hash,"ds2438.getvdd",1,undef,$owx_dev,undef,undef,substr($res,11));
|
OWXMULTI_BinValues($hash,"ds2438.getvdd",1,undef,$owx_dev,undef,undef,substr($res,11));
|
||||||
}
|
}
|
||||||
#------------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------------
|
||||||
@ -994,9 +995,10 @@ sub OWXMULTI_GetValues($$) {
|
|||||||
OWX_Reset($master);
|
OWX_Reset($master);
|
||||||
$res=OWX_Complex($master,$owx_dev,"\xBE\x00",9);
|
$res=OWX_Complex($master,$owx_dev,"\xBE\x00",9);
|
||||||
#-- process results
|
#-- process results
|
||||||
if( $res eq 0 ){
|
return "$owx_dev not accessible in 2nd step"
|
||||||
return "$owx_dev not accessible in 2nd step";
|
if( $res eq 0 );
|
||||||
}
|
return "$owx_dev has returned invalid data"
|
||||||
|
if( length($res)!=20);
|
||||||
OWXMULTI_BinValues($hash,"ds2438.getvad",1,undef,$owx_dev,undef,undef,substr($res,11));
|
OWXMULTI_BinValues($hash,"ds2438.getvad",1,undef,$owx_dev,undef,undef,substr($res,11));
|
||||||
}
|
}
|
||||||
return undef;
|
return undef;
|
||||||
|
@ -76,7 +76,7 @@ use strict;
|
|||||||
use warnings;
|
use warnings;
|
||||||
sub Log($$);
|
sub Log($$);
|
||||||
|
|
||||||
my $owx_version="5.06";
|
my $owx_version="5.11";
|
||||||
#-- fixed raw channel name, flexible channel name
|
#-- fixed raw channel name, flexible channel name
|
||||||
my @owg_fixed = ("A","B","C","D","E","F","G","H");
|
my @owg_fixed = ("A","B","C","D","E","F","G","H");
|
||||||
my @owg_channel = ("A","B","C","D","E","F","G","H");
|
my @owg_channel = ("A","B","C","D","E","F","G","H");
|
||||||
@ -1123,9 +1123,10 @@ sub OWXSWITCH_GetState($) {
|
|||||||
}else{
|
}else{
|
||||||
OWX_Reset($master);
|
OWX_Reset($master);
|
||||||
$res=OWX_Complex($master,$owx_dev,$select,4);
|
$res=OWX_Complex($master,$owx_dev,$select,4);
|
||||||
if( $res eq 0 ){
|
return "$owx_dev not accessible in reading"
|
||||||
return "not accessible in reading";
|
if( $res eq 0 );
|
||||||
}
|
return "$owx_dev has returned invalid data"
|
||||||
|
if( length($res)!=16);
|
||||||
OWX_Reset($master);
|
OWX_Reset($master);
|
||||||
OWXSWITCH_BinValues($hash,"ds2406.getstate",1,undef,$owx_dev,substr($res,9,3),undef,substr($res,12));
|
OWXSWITCH_BinValues($hash,"ds2406.getstate",1,undef,$owx_dev,substr($res,9,3),undef,substr($res,12));
|
||||||
}
|
}
|
||||||
@ -1148,9 +1149,10 @@ sub OWXSWITCH_GetState($) {
|
|||||||
}else{
|
}else{
|
||||||
OWX_Reset($master);
|
OWX_Reset($master);
|
||||||
$res=OWX_Complex($master,$owx_dev,$select,10);
|
$res=OWX_Complex($master,$owx_dev,$select,10);
|
||||||
if( $res eq 0 ){
|
return "$owx_dev not accessible in reading"
|
||||||
return "not accessible in reading";
|
if( $res eq 0 );
|
||||||
}
|
return "$owx_dev has returned invalid data"
|
||||||
|
if( length($res)!=22);
|
||||||
OWX_Reset($master);
|
OWX_Reset($master);
|
||||||
return OWXSWITCH_BinValues($hash,"ds2408.getstate",1,undef,$owx_dev,substr($res,9,3),undef,substr($res,12));
|
return OWXSWITCH_BinValues($hash,"ds2408.getstate",1,undef,$owx_dev,substr($res,9,3),undef,substr($res,12));
|
||||||
}
|
}
|
||||||
@ -1172,10 +1174,11 @@ sub OWXSWITCH_GetState($) {
|
|||||||
}else{
|
}else{
|
||||||
OWX_Reset($master);
|
OWX_Reset($master);
|
||||||
$res=OWX_Complex($master,$owx_dev,"\xF5",2);
|
$res=OWX_Complex($master,$owx_dev,"\xF5",2);
|
||||||
if( $res eq 0 ){
|
return "$owx_dev not accessible in reading"
|
||||||
return "not accessible in reading";
|
if( $res eq 0 );
|
||||||
}
|
return "$owx_dev has returned invalid data"
|
||||||
OWX_Reset($master);
|
if( length($res)!=12);
|
||||||
|
#OWX_Reset($master);
|
||||||
return OWXSWITCH_BinValues($hash,"ds2413.getstate",1,undef,$owx_dev,substr($res,9,1),undef,substr($res,10));
|
return OWXSWITCH_BinValues($hash,"ds2413.getstate",1,undef,$owx_dev,substr($res,9,1),undef,substr($res,10));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -75,7 +75,7 @@ use warnings;
|
|||||||
sub Log($$);
|
sub Log($$);
|
||||||
sub AttrVal($$$);
|
sub AttrVal($$$);
|
||||||
|
|
||||||
my $owx_version="5.06";
|
my $owx_version="5.11";
|
||||||
|
|
||||||
my %gets = (
|
my %gets = (
|
||||||
"id" => "",
|
"id" => "",
|
||||||
@ -966,9 +966,10 @@ sub OWXTHERM_GetValues($) {
|
|||||||
} else {
|
} else {
|
||||||
OWX_Reset($master);
|
OWX_Reset($master);
|
||||||
my $res=OWX_Complex($master,$owx_dev,"\xBE",9);
|
my $res=OWX_Complex($master,$owx_dev,"\xBE",9);
|
||||||
if( $res eq 0 ){
|
return "$owx_dev not accessible in reading"
|
||||||
return "$owx_dev not accessible in reading";
|
if( $res eq 0 );
|
||||||
}
|
return "$owx_dev has returned invalid data"
|
||||||
|
if( length($res)!=19);
|
||||||
OWXTHERM_BinValues($hash,"ds182x.reading",1,undef,$owx_dev,undef,undef,substr($res,10,9));
|
OWXTHERM_BinValues($hash,"ds182x.reading",1,undef,$owx_dev,undef,undef,substr($res,10,9));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user