1
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-05-04 22:19:38 +00:00

added try handling to hardware access

removed altitude from readings

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

View File

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