mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-02-08 05:15:10 +00:00
52_I2C_SHT21: modified for use with 10_FRM
10_FRM: more logigal devices added 51_RPI_GPIO: better failure log 52_I2C_MCP23008: bufix for poll_interval 52_I2C_MCP23017: bufix for poll_interval 52_I2C_PCA9532: bufix for poll_interval git-svn-id: https://svn.fhem.de/fhem/trunk@9258 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
2a45ec2da8
commit
15d75dd09a
@ -23,9 +23,10 @@ my @clients = qw(
|
||||
I2C_LCD
|
||||
I2C_DS1307
|
||||
I2C_PC.*
|
||||
I2C_MCP23017
|
||||
I2C_MCP23.*
|
||||
I2C_BMP180
|
||||
I2C_SHT21
|
||||
I2C_TSL2561
|
||||
);
|
||||
|
||||
sub NetzerI2C_Initialize($) {
|
||||
|
@ -49,8 +49,10 @@ my @clients = qw(
|
||||
I2C_LCD
|
||||
I2C_DS1307
|
||||
I2C_PC.*
|
||||
I2C_MCP23017
|
||||
I2C_MCP23.*
|
||||
I2C_SHT21
|
||||
I2C_BMP180
|
||||
I2C_TSL2561
|
||||
FRM_LCD
|
||||
);
|
||||
|
||||
|
@ -102,18 +102,32 @@ sub RPI_GPIO_Define($$) {
|
||||
$counter --;
|
||||
}
|
||||
unless( $counter ) { #abbrechen wenn export fehlgeschlagen
|
||||
#nochmal probieren wenn keine Schreibrechte##########
|
||||
# nochmal probieren wenn keine Schreibrechte auf GPIO Dateien ##########
|
||||
if ( defined(my $ret = RPI_GPIO_CHECK_GPIO_UTIL($gpioprg)) ) { #Abbbruch da kein gpio utility vorhanden
|
||||
Log3 $hash, 1, "$name: can't export gpio$hash->{RPI_pin}, no write access to $gpiodir/export and " . $ret;
|
||||
Log3 $hash, 1, "$name: failed to export pin gpio$hash->{RPI_pin}";
|
||||
return "$name: failed to export pin gpio$hash->{RPI_pin}";
|
||||
} else { #nutze GPIO Utility?
|
||||
Log3 $hash, 4, "$name: using gpio utility to export pin (first export failed)";
|
||||
if ( -e "$gpiodir/export") {
|
||||
Log3 $hash, 1, "$name: \"$gpiodir/export\" exists and is " . ( ( -w "$gpiodir/export") ? "" : "NOT " ) . "writable";
|
||||
} else {
|
||||
Log3 $hash, 1, "$name: gpio$hash->{RPI_pin}/value doesnt exist";
|
||||
}
|
||||
if(-e "$gpiodir/gpio$hash->{RPI_pin}") {
|
||||
Log3 $hash, 1, "$name: \"$gpiodir/gpio$hash->{RPI_pin}\" exported but define aborted:";
|
||||
if ( -e "$gpiodir/gpio$hash->{RPI_pin}/value") {
|
||||
Log3 $hash, 1, "$name: \"$gpiodir/gpio$hash->{RPI_pin}/value\" exists and is " . ( ( -w "$gpiodir/gpio$hash->{RPI_pin}/value") ? "" : "NOT " ) . "writable";
|
||||
} else {
|
||||
Log3 $hash, 1, "$name: \"$gpiodir/gpio$hash->{RPI_pin}/value\" doesnt exist";
|
||||
}
|
||||
if ( -e "$gpiodir/gpio$hash->{RPI_pin}/direction") {
|
||||
Log3 $hash, 1, "$name: \"$gpiodir/gpio$hash->{RPI_pin}/direction\" exists and is " . ( ( -w "$gpiodir/gpio$hash->{RPI_pin}/direction") ? "" : "NOT " ) . "writable";
|
||||
} else {
|
||||
Log3 $hash, 1, "$name: \"$gpiodir/gpio$hash->{RPI_pin}/direction\" doesnt exist";
|
||||
}
|
||||
Log3 $hash, 1, "$name: second attempt to export gpio$hash->{RPI_pin} failed: " . $ret;
|
||||
}
|
||||
return "$name: failed to export pin gpio$hash->{RPI_pin}, see logfile";
|
||||
} else { #nutze GPIO Utility fuer zweiten Exportversuch
|
||||
Log3 $hash, 4, "$name: using gpio utility to export pin (first export via $gpiodir/export failed)";
|
||||
RPI_GPIO_exuexpin($hash, "in");
|
||||
}
|
||||
#####################################################
|
||||
# Log3 $hash, 1, "$name: failed to export pin gpio$hash->{RPI_pin}";
|
||||
# return "$name: failed to export pin gpio$hash->{RPI_pin}";
|
||||
}
|
||||
|
||||
$hash->{fhem}{interfaces} = "switch";
|
||||
|
@ -178,11 +178,22 @@ sub I2C_SHT21_I2CRec ($$) {
|
||||
while ( my ( $k, $v ) = each %$clientmsg ) { #erzeugen von Internals fuer alle Keys in $clientmsg die mit dem physical Namen beginnen
|
||||
$hash->{$k} = $v if $k =~ /^$pname/ ;
|
||||
}
|
||||
if ($clientmsg->{direction} && $clientmsg->{type} && $clientmsg->{$pname . "_SENDSTAT"} && $clientmsg->{$pname . "_SENDSTAT"} eq "Ok") {
|
||||
#alte Variante zur Temp Hum Unterscheidung
|
||||
#if ( $clientmsg->{direction} && $clientmsg->{type} && $clientmsg->{$pname . "_SENDSTAT"} && $clientmsg->{$pname . "_SENDSTAT"} eq "Ok" ) {
|
||||
# if ( $clientmsg->{direction} eq "i2cread" && defined($clientmsg->{received}) ) {
|
||||
# Log3 $hash, 5, "empfangen: $clientmsg->{received}";
|
||||
# I2C_SHT21_GetTemp ($hash, $clientmsg->{received}) if $clientmsg->{type} eq "temp" && $clientmsg->{nbyte} == 2;
|
||||
# I2C_SHT21_GetHum ($hash, $clientmsg->{received}) if $clientmsg->{type} eq "hum" && $clientmsg->{nbyte} == 2;
|
||||
# }
|
||||
#}
|
||||
|
||||
# Bit 1 of the two LSBs indicates the measurement type (‘0’: temperature, ‘1’ humidity)
|
||||
if ( $clientmsg->{direction} && $clientmsg->{$pname . "_SENDSTAT"} && $clientmsg->{$pname . "_SENDSTAT"} eq "Ok" ) {
|
||||
if ( $clientmsg->{direction} eq "i2cread" && defined($clientmsg->{received}) ) {
|
||||
Log3 $hash, 5, "empfangen: $clientmsg->{received}";
|
||||
I2C_SHT21_GetTemp ($hash, $clientmsg->{received}) if $clientmsg->{type} eq "temp" && $clientmsg->{nbyte} == 2;
|
||||
I2C_SHT21_GetHum ($hash, $clientmsg->{received}) if $clientmsg->{type} eq "hum" && $clientmsg->{nbyte} == 2;
|
||||
my @raw = split(" ",$clientmsg->{received});
|
||||
I2C_SHT21_GetTemp ($hash, $clientmsg->{received}) if !($raw[1] & 2) && $clientmsg->{nbyte} == 2;
|
||||
I2C_SHT21_GetHum ($hash, $clientmsg->{received}) if ($raw[1] & 2) && $clientmsg->{nbyte} == 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user