mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-01-31 06:39:11 +00:00
Small EM fixes
git-svn-id: https://svn.fhem.de/fhem/trunk@66 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
550b1d524d
commit
43770b4247
@ -93,7 +93,7 @@ sub
|
||||
b($$)
|
||||
{
|
||||
my ($t,$p) = @_;
|
||||
return -1 if(length($t) < $p);
|
||||
return -1 if(!defined($t) || length($t) < $p);
|
||||
return ord(substr($t,$p,1));
|
||||
}
|
||||
|
||||
@ -123,6 +123,8 @@ EM_Get($@)
|
||||
if($a[1] eq "time") {
|
||||
|
||||
my $d = EmGetData($hash->{DeviceName}, "74");
|
||||
return "Read error" if(!defined($d));
|
||||
|
||||
$v = sprintf "%4d-%02d-%02d %02d:%02d:%02d",
|
||||
b($d,5)+2006, b($d,4), b($d,3),
|
||||
b($d,0), b($d,1), b($d,2);
|
||||
@ -130,6 +132,7 @@ EM_Get($@)
|
||||
} elsif($a[1] eq "version") {
|
||||
|
||||
my $d = EmGetData($hash->{DeviceName},"76");
|
||||
return "Read error" if(!defined($d));
|
||||
$v = sprintf "%d.%d", b($d,0), b($d,1);
|
||||
|
||||
} else {
|
||||
|
@ -35,10 +35,16 @@ EMWZ_GetStatus($)
|
||||
}
|
||||
|
||||
my $dnr = $hash->{DEVNR};
|
||||
my $d = IOWrite($hash, sprintf("7a%02x", $dnr-1));
|
||||
|
||||
my $name = $hash->{NAME};
|
||||
|
||||
my $d = IOWrite($hash, sprintf("7a%02x", $dnr-1));
|
||||
if(!defined($d)) {
|
||||
my $msg = "EMWZ $name read error";
|
||||
Log GetLogLevel($name,2), $msg;
|
||||
return $msg;
|
||||
}
|
||||
|
||||
|
||||
if($d eq ((pack('H*',"00") x 45) . pack('H*',"FF") x 6)) {
|
||||
my $msg = "EMWZ no device no. $dnr present";
|
||||
Log GetLogLevel($name,2), $msg;
|
||||
@ -118,6 +124,7 @@ EMWZ_Set($@)
|
||||
my $v = $a[2];
|
||||
my $d = $hash->{DEVNR};
|
||||
my $msg;
|
||||
my $name = $hash->{NAME};
|
||||
|
||||
if($a[1] eq "price") {
|
||||
$v *= 10000; # Make display and input the same
|
||||
@ -132,9 +139,15 @@ EMWZ_Set($@)
|
||||
}
|
||||
|
||||
my $ret = IOWrite($hash, $msg);
|
||||
if(!defined($d)) {
|
||||
my $msg = "EMWZ $name read error";
|
||||
Log GetLogLevel($name,2), $msg;
|
||||
return $msg;
|
||||
}
|
||||
|
||||
if(ord(substr($ret,0,1)) != 6) {
|
||||
$ret = "EMWZ Error occured: " . unpack('H*', $ret);
|
||||
Log GetLogLevel($hash->{NAME},2), $ret;
|
||||
Log GetLogLevel($name,2), $ret;
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user