2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-01-31 18:59:33 +00:00

added try handling to hardware access

removed altitude from readings

git-svn-id: https://svn.fhem.de/fhem/trunk@5359 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
klauswitt 2014-03-28 23:03:51 +00:00
parent 8124494a31
commit af868f9d58

View File

@ -36,7 +36,7 @@ use warnings;
use Time::HiRes qw(usleep);
use Scalar::Util qw(looks_like_number);
#use Error qw(:try);
use Error qw(:try);
use constant {
BMP180_I2C_ADDRESS => '0x77',
@ -357,7 +357,7 @@ sub I2C_BMP180_GetPress ($$) {
readingsBulkUpdate($hash, 'temperature', $temperature);
readingsBulkUpdate($hash, 'pressure', $pressure);
readingsBulkUpdate($hash, 'pressure-nn', $pressureNN);
readingsBulkUpdate($hash, 'altitude', $altitude, 0);
#readingsBulkUpdate($hash, 'altitude', $altitude, 0);
readingsEndUpdate($hash, 1);
}
@ -418,6 +418,7 @@ sub I2C_BMP180_readUncompensatedPressure($$) {
sub I2C_BMP180_i2cread($$$) {
my ($hash, $reg, $nbyte) = @_;
if ($hash->{HiPi_used}) {
try {
my @values = $hash->{devBPM180}->bus_read($reg, $nbyte);
I2C_BMP180_I2CRec($hash, {
direction => "i2cread",
@ -426,6 +427,9 @@ sub I2C_BMP180_i2cread($$$) {
nbyte => $nbyte,
received => join (' ',@values),
});
} catch Error with {
Log3 ($hash, 1, ': ERROR: '. $hash->{NAME} . ': i2c-bus_read failure');
};
} else {
if (defined (my $iodev = $hash->{IODev})) {
CallFn($iodev->{NAME}, "I2CWrtFn", $iodev, {
@ -443,6 +447,7 @@ sub I2C_BMP180_i2cread($$$) {
sub I2C_BMP180_i2cwrite($$$) {
my ($hash, $reg, @data) = @_;
if ($hash->{HiPi_used}) {
try {
$hash->{devBPM180}->bus_write($reg, join (' ',@data));
I2C_BMP180_I2CRec($hash, {
direction => "i2cwrite",
@ -450,6 +455,9 @@ sub I2C_BMP180_i2cwrite($$$) {
reg => $reg,
data => join (' ',@data),
});
} catch Error with {
Log3 ($hash, 1, ': ERROR: ' . $hash->{NAME} . ': i2c-bus_write failure');
};
} else {
if (defined (my $iodev = $hash->{IODev})) {
CallFn($iodev->{NAME}, "I2CWrtFn", $iodev, {