mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-04-19 06:36:04 +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_LCD
|
||||||
I2C_DS1307
|
I2C_DS1307
|
||||||
I2C_PC.*
|
I2C_PC.*
|
||||||
I2C_MCP23017
|
I2C_MCP23.*
|
||||||
I2C_BMP180
|
I2C_BMP180
|
||||||
I2C_SHT21
|
I2C_SHT21
|
||||||
|
I2C_TSL2561
|
||||||
);
|
);
|
||||||
|
|
||||||
sub NetzerI2C_Initialize($) {
|
sub NetzerI2C_Initialize($) {
|
||||||
|
@ -49,8 +49,10 @@ my @clients = qw(
|
|||||||
I2C_LCD
|
I2C_LCD
|
||||||
I2C_DS1307
|
I2C_DS1307
|
||||||
I2C_PC.*
|
I2C_PC.*
|
||||||
I2C_MCP23017
|
I2C_MCP23.*
|
||||||
|
I2C_SHT21
|
||||||
I2C_BMP180
|
I2C_BMP180
|
||||||
|
I2C_TSL2561
|
||||||
FRM_LCD
|
FRM_LCD
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -102,18 +102,32 @@ sub RPI_GPIO_Define($$) {
|
|||||||
$counter --;
|
$counter --;
|
||||||
}
|
}
|
||||||
unless( $counter ) { #abbrechen wenn export fehlgeschlagen
|
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
|
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;
|
if ( -e "$gpiodir/export") {
|
||||||
Log3 $hash, 1, "$name: failed to export pin gpio$hash->{RPI_pin}";
|
Log3 $hash, 1, "$name: \"$gpiodir/export\" exists and is " . ( ( -w "$gpiodir/export") ? "" : "NOT " ) . "writable";
|
||||||
return "$name: failed to export pin gpio$hash->{RPI_pin}";
|
} else {
|
||||||
} else { #nutze GPIO Utility?
|
Log3 $hash, 1, "$name: gpio$hash->{RPI_pin}/value doesnt exist";
|
||||||
Log3 $hash, 4, "$name: using gpio utility to export pin (first export failed)";
|
}
|
||||||
|
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");
|
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";
|
$hash->{fhem}{interfaces} = "switch";
|
||||||
|
@ -57,7 +57,7 @@ sub I2C_MCP23008_Initialize($) {
|
|||||||
$hash->{SetFn} = "I2C_MCP23008_Set";
|
$hash->{SetFn} = "I2C_MCP23008_Set";
|
||||||
$hash->{GetFn} = "I2C_MCP23008_Get";
|
$hash->{GetFn} = "I2C_MCP23008_Get";
|
||||||
$hash->{I2CRecFn} = "I2C_MCP23008_I2CRec";
|
$hash->{I2CRecFn} = "I2C_MCP23008_I2CRec";
|
||||||
$hash->{AttrList} = "IODev do_not_notify:1,0 ignore:1,0 showtime:1,0".
|
$hash->{AttrList} = "IODev do_not_notify:1,0 ignore:1,0 showtime:1,0 ".
|
||||||
"poll_interval OnStartup ".
|
"poll_interval OnStartup ".
|
||||||
"OutputPorts:multiple-strict,A0,A1,A2,A3,A4,A5,A6,A7 ".
|
"OutputPorts:multiple-strict,A0,A1,A2,A3,A4,A5,A6,A7 ".
|
||||||
"Pullup:multiple-strict,A0,A1,A2,A3,A4,A5,A6,A7 ".
|
"Pullup:multiple-strict,A0,A1,A2,A3,A4,A5,A6,A7 ".
|
||||||
|
@ -60,7 +60,7 @@ sub I2C_MCP23017_Initialize($) {
|
|||||||
$hash->{SetFn} = "I2C_MCP23017_Set";
|
$hash->{SetFn} = "I2C_MCP23017_Set";
|
||||||
$hash->{GetFn} = "I2C_MCP23017_Get";
|
$hash->{GetFn} = "I2C_MCP23017_Get";
|
||||||
$hash->{I2CRecFn} = "I2C_MCP23017_I2CRec";
|
$hash->{I2CRecFn} = "I2C_MCP23017_I2CRec";
|
||||||
$hash->{AttrList} = "IODev do_not_notify:1,0 ignore:1,0 showtime:1,0".
|
$hash->{AttrList} = "IODev do_not_notify:1,0 ignore:1,0 showtime:1,0 ".
|
||||||
"poll_interval OnStartup ".
|
"poll_interval OnStartup ".
|
||||||
"OutputPorts:multiple-strict,A0,A1,A2,A3,A4,A5,A6,A7,B0,B1,B2,B3,B4,B5,B6,B7 ".
|
"OutputPorts:multiple-strict,A0,A1,A2,A3,A4,A5,A6,A7,B0,B1,B2,B3,B4,B5,B6,B7 ".
|
||||||
"Pullup:multiple-strict,A0,A1,A2,A3,A4,A5,A6,A7,B0,B1,B2,B3,B4,B5,B6,B7 ".
|
"Pullup:multiple-strict,A0,A1,A2,A3,A4,A5,A6,A7,B0,B1,B2,B3,B4,B5,B6,B7 ".
|
||||||
|
@ -46,7 +46,7 @@ sub I2C_PCA9532_Initialize($) {
|
|||||||
$hash->{SetFn} = "I2C_PCA9532_Set";
|
$hash->{SetFn} = "I2C_PCA9532_Set";
|
||||||
$hash->{GetFn} = "I2C_PCA9532_Get";
|
$hash->{GetFn} = "I2C_PCA9532_Get";
|
||||||
$hash->{I2CRecFn} = "I2C_PCA9532_I2CRec";
|
$hash->{I2CRecFn} = "I2C_PCA9532_I2CRec";
|
||||||
$hash->{AttrList} = "IODev do_not_notify:1,0 ignore:1,0 showtime:1,0".
|
$hash->{AttrList} = "IODev do_not_notify:1,0 ignore:1,0 showtime:1,0 ".
|
||||||
"poll_interval T0:slider,0,1,255 T1:slider,0,1,255 OnStartup InputPorts ".
|
"poll_interval T0:slider,0,1,255 T1:slider,0,1,255 OnStartup InputPorts ".
|
||||||
"OutputPorts:multiple-strict,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 ".
|
"OutputPorts:multiple-strict,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 ".
|
||||||
"$readingFnAttributes";
|
"$readingFnAttributes";
|
||||||
|
@ -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
|
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/ ;
|
$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}) ) {
|
if ( $clientmsg->{direction} eq "i2cread" && defined($clientmsg->{received}) ) {
|
||||||
Log3 $hash, 5, "empfangen: $clientmsg->{received}";
|
Log3 $hash, 5, "empfangen: $clientmsg->{received}";
|
||||||
I2C_SHT21_GetTemp ($hash, $clientmsg->{received}) if $clientmsg->{type} eq "temp" && $clientmsg->{nbyte} == 2;
|
my @raw = split(" ",$clientmsg->{received});
|
||||||
I2C_SHT21_GetHum ($hash, $clientmsg->{received}) if $clientmsg->{type} eq "hum" && $clientmsg->{nbyte} == 2;
|
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