mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-02-07 23:09:26 +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:
parent
8124494a31
commit
af868f9d58
@ -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,6 +418,7 @@ 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}) {
|
||||||
|
try {
|
||||||
my @values = $hash->{devBPM180}->bus_read($reg, $nbyte);
|
my @values = $hash->{devBPM180}->bus_read($reg, $nbyte);
|
||||||
I2C_BMP180_I2CRec($hash, {
|
I2C_BMP180_I2CRec($hash, {
|
||||||
direction => "i2cread",
|
direction => "i2cread",
|
||||||
@ -426,6 +427,9 @@ sub I2C_BMP180_i2cread($$$) {
|
|||||||
nbyte => $nbyte,
|
nbyte => $nbyte,
|
||||||
received => join (' ',@values),
|
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,6 +447,7 @@ 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}) {
|
||||||
|
try {
|
||||||
$hash->{devBPM180}->bus_write($reg, join (' ',@data));
|
$hash->{devBPM180}->bus_write($reg, join (' ',@data));
|
||||||
I2C_BMP180_I2CRec($hash, {
|
I2C_BMP180_I2CRec($hash, {
|
||||||
direction => "i2cwrite",
|
direction => "i2cwrite",
|
||||||
@ -450,6 +455,9 @@ sub I2C_BMP180_i2cwrite($$$) {
|
|||||||
reg => $reg,
|
reg => $reg,
|
||||||
data => join (' ',@data),
|
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, {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user