Firmata mit TSL2561

Begonnen von eitschdie, 09 September 2015, 15:54:56

Vorheriges Thema - Nächstes Thema

jensb

Hier gehts weiter:
Zitat
2015.11.22 12:19:37 5: FRM: Adresse: 57|Register: 138|1 byte(s)
Use of uninitialized value in string eq at ./FHEM/51_I2C_TSL2561.pm line 1372.

Dahinter steckt, wie du ja bereits herausgefunden hast:

if ($hash->{$iodev->{NAME}.'_SENDSTAT'} eq 'error') {
      readingsSingleUpdate($hash, 'state', STATE_I2C_ERROR, 1);
      $success = 0;
}

Kannst du die Readings deines IODev zu diesem Zeitpunkt abfragen?

Eine mögliche Variante wäre nun:

if (!defined($hash->{$iodev->{NAME}.'_SENDSTAT'}) || $hash->{$iodev->{NAME}.'_SENDSTAT'} eq 'error') {
      readingsSingleUpdate($hash, 'state', STATE_I2C_ERROR, 1);
      $success = 0;
}

unter der Annahme, das dein IODev eigentlich nach dem 1. Senden das Reading "_SENDSTAT" haben müsste.

Alternativ, unter der Annahme, dass eigentlich alles gut ist:

if (defined($hash->{$iodev->{NAME}.'_SENDSTAT'}) && $hash->{$iodev->{NAME}.'_SENDSTAT'} eq 'error') {
      readingsSingleUpdate($hash, 'state', STATE_I2C_ERROR, 1);
      $success = 0;
}


Bitte probiere die beiden Varianten aus.

LG, Jens
FHEM 6.1 - RPi 4 Raspbian 12 + PiTFT - OPi Zero Armbian 5.35
EnOcean - (W)LAN/Firmata: BMP180, TSL2561, SHT21, Heatronic 3, OBIS - WLAN/ESP8266: Gardena 1251, Zirkulationspumpe - RTL433: Oregon - Bluetooth - MQTT
Contributions: https://svn.fhem.de/trac/browser/trunk/fhem/contrib/jensb

thymjan

Bei der ersten Variante ist die Fehlermeldung weg:
2015.11.22 13:25:52 5: I2C_TSL2561_Poll: start
2015.11.22 13:25:52 5: I2C_TSL2561_GetLuminosity: calc state 0 acqui state 0
2015.11.22 13:25:52 5: I2C_TSL2561_GetLuminosity: starting new measurement
2015.11.22 13:25:52 5: I2C_TSL2561_Enable: start
2015.11.22 13:25:52 5: FRM: Kommunikation mit I2C ...
2015.11.22 13:25:52 5: FRM: auf I2C lesen ...
2015.11.22 13:25:52 5: FRM:>f07639080a010100f7
2015.11.22 13:25:52 5: FRM: Adresse: 57|Register: 138|1 byte(s)
2015.11.22 13:25:52 5: I2C_TSL2561_Enable: end
2015.11.22 13:25:52 5: I2C_TSL2561_Disable: start
2015.11.22 13:25:52 5: FRM: Kommunikation mit I2C ...
2015.11.22 13:25:52 5: FRM: auf I2C schreiben ...
2015.11.22 13:25:52 5: FRM: Adresse: 57|Register: 128|Wert: 0
2015.11.22 13:25:52 5: FRM:>f076390000010000f7
2015.11.22 13:25:52 5: I2C_TSL2561_Disable: end
2015.11.22 13:25:52 5: I2C_TSL2561_GetLuminosity: calc state 3 acqui state 0
2015.11.22 13:25:52 5: I2C_TSL2561_GetLuminosity: error, aborting
2015.11.22 13:25:52 1: PERL WARNING: Use of uninitialized value in multiplication (*) at ./FHEM/51_I2C_TSL2561.pm line 582.
2015.11.22 13:25:52 1: PERL WARNING: Use of uninitialized value in multiplication (*) at ./FHEM/51_I2C_TSL2561.pm line 583.
2015.11.22 13:25:52 5: I2C_TSL2561_Poll: 60 s
2015.11.22 13:25:54 5: FRM:<f07739000a015000f7
2015.11.22 13:25:54 5: --------------------------
2015.11.22 13:25:54 5: FRM: onI2CMessage address: '57', register: '138' data: [80]
2015.11.22 13:25:54 5: FRM: UPDATE Adresse: 57|Register: 138|Daten: 80
2015.11.22 13:25:54 5: FRM: UPDATE FRM_1_SENDSTAT => "Ok"
2015.11.22 13:25:54 5: Lichtsensor RX register 10, 1 byte: 80
2015.11.22 13:25:54 5: I2C_TSL2561_I2CRcvID: sensorId TSL2561 Package T/FN/CL Rev. 0


Bei der Variante 2 auch:
2015.11.22 13:31:40 5: I2C_TSL2561_Poll: start
2015.11.22 13:31:40 5: I2C_TSL2561_GetLuminosity: calc state 0 acqui state 0
2015.11.22 13:31:40 5: I2C_TSL2561_GetLuminosity: starting new measurement
2015.11.22 13:31:40 5: I2C_TSL2561_Enable: start
2015.11.22 13:31:40 5: FRM: Kommunikation mit I2C ...
2015.11.22 13:31:40 5: FRM: auf I2C lesen ...
2015.11.22 13:31:40 5: FRM:>f07639080a010100f7
2015.11.22 13:31:40 5: FRM: Adresse: 57|Register: 138|1 byte(s)
2015.11.22 13:31:40 5: I2C_TSL2561_Enable: end
2015.11.22 13:31:40 5: I2C_TSL2561_Disable: start
2015.11.22 13:31:40 5: FRM: Kommunikation mit I2C ...
2015.11.22 13:31:40 5: FRM: auf I2C schreiben ...
2015.11.22 13:31:40 5: FRM: Adresse: 57|Register: 128|Wert: 0
2015.11.22 13:31:40 5: FRM:>f076390000010000f7
2015.11.22 13:31:40 5: I2C_TSL2561_Disable: end
2015.11.22 13:31:40 5: I2C_TSL2561_GetLuminosity: calc state 3 acqui state 0
2015.11.22 13:31:40 5: I2C_TSL2561_GetLuminosity: error, aborting
2015.11.22 13:31:40 1: PERL WARNING: Use of uninitialized value in multiplication (*) at ./FHEM/51_I2C_TSL2561.pm line 582.
2015.11.22 13:31:40 1: PERL WARNING: Use of uninitialized value in multiplication (*) at ./FHEM/51_I2C_TSL2561.pm line 583.
2015.11.22 13:31:40 5: I2C_TSL2561_Poll: 60 s
2015.11.22 13:31:40 5: FRM:<f07739000a015000f7
2015.11.22 13:31:40 5: --------------------------
2015.11.22 13:31:40 5: FRM: onI2CMessage address: '57', register: '138' data: [80]
2015.11.22 13:31:40 5: FRM: UPDATE Adresse: 57|Register: 138|Daten: 80
2015.11.22 13:31:40 5: FRM: UPDATE FRM_1_SENDSTAT => "Ok"
2015.11.22 13:31:40 5: Lichtsensor RX register 10, 1 byte: 80
2015.11.22 13:31:40 5: I2C_TSL2561_I2CRcvID: sensorId TSL2561 Package T/FN/CL Rev. 0


Mein IODev (FRM_1) erzeugt hier keine Readings.

Die Readings bzw. List von meinem Sensor:
Internals:
   DEF        0x39
   FRM_1_SENDSTAT Ok
   HiPi_used  0
   I2C_Address 57
   IODev      FRM_1
   NAME       Lichtsensor
   NR         123
   STATE      B: 0 I: 0 L: luminosity
   TYPE       I2C_TSL2561
   acquiState 0
   autoAddress 0
   calcState  0
   sensorEnabled 0
   sensorType TSL2561 Package T/FN/CL Rev. 0
   tsl2561Gain 16
   tsl2561IntegrationTime 1
   tsl2561Package 5
   Readings:
     2015-11-22 13:33:50   broadband       0
     2015-11-22 13:33:50   gain            16
     2015-11-22 13:33:50   integrationTime 0.101
     2015-11-22 13:33:50   ir              0
     2015-11-22 13:33:50   state           I2C Error
Attributes:
   IODev      FRM_1
   autoGain   1
   autoIntegrationTime 1
   floatArithmetics 1
   gain       16
   icon       weather_light_meter
   integrationTime 101
   normalizeRawValues 1
   poll_interval 1
   room       firmata
   stateFormat B: broadband I: ir L: luminosity
   verbose    5

jensb

Mit beiden Varianten scheint auf jeden Fall die Grundinitalisierung durchzulaufen, denn du bekommst:
Zitat
2015.11.22 13:25:54 5: I2C_TSL2561_I2CRcvID: sensorId TSL2561 Package T/FN/CL Rev. 0

Sehe ich das richtig, dass der 1. I2C-Zugriff reg138=80 ca. 2 Sekunden benötigt, um tatsächlich ausgeführt zu werden?
Zitat
2015.11.22 13:25:52 5: FRM: Adresse: 57|Register: 138|1 byte(s)
...
2015.11.22 13:25:54 5: FRM: UPDATE Adresse: 57|Register: 138|Daten: 80
2015.11.22 13:25:54 5: Lichtsensor RX register 10, 1 byte: 80
Hier steckt das Hauptproblem. Beim bisherigen Ansatz mit HiPi war der Bus-Zugriff blockend. Mit IODev unter Firmata geht das so nicht.

Kann man hier vielleicht die Blockierung wieder herstellen, indem man in i2cread/write wartet, bis I2CRec die Daten hat, ohne komplett zu blockieren?

Werde dass mal bei mir einbauen und testen, ob es zumindest ohne Firmata dann noch funktioniert.

Jens


FHEM 6.1 - RPi 4 Raspbian 12 + PiTFT - OPi Zero Armbian 5.35
EnOcean - (W)LAN/Firmata: BMP180, TSL2561, SHT21, Heatronic 3, OBIS - WLAN/ESP8266: Gardena 1251, Zirkulationspumpe - RTL433: Oregon - Bluetooth - MQTT
Contributions: https://svn.fhem.de/trac/browser/trunk/fhem/contrib/jensb

thymjan

#48
2015.11.22 14:17:08 5: I2C_TSL2561_Poll: start
2015.11.22 14:17:08 5: I2C_TSL2561_GetLuminosity: calc state 0 acqui state 0
2015.11.22 14:17:08 5: I2C_TSL2561_GetLuminosity: starting new measurement
2015.11.22 14:17:08 5: I2C_TSL2561_Enable: start
2015.11.22 14:17:08 5: I2C_TSL2561_i2cread: calling CallFn now...
2015.11.22 14:17:08 5: FRM: Kommunikation mit I2C ...
2015.11.22 14:17:08 5: FRM: auf I2C lesen ...
2015.11.22 14:17:08 5: FRM:>f07639080a010100f7
2015.11.22 14:17:08 5: FRM: Adresse: 57|Register: 138|1 byte(s)
2015.11.22 14:17:08 5: I2C_TSL2561_i2cwrite: Address 57 | Register 138
2015.11.22 14:17:08 5: I2C_TSL2561_Enable: end
2015.11.22 14:17:08 5: I2C_TSL2561_Disable: start
2015.11.22 14:17:08 5: I2C_TSL2561_i2cwrite: calling CallFn now...
2015.11.22 14:17:08 5: FRM: Kommunikation mit I2C ...
2015.11.22 14:17:08 5: FRM: auf I2C schreiben ...
2015.11.22 14:17:08 5: FRM: Adresse: 57|Register: 128|Wert: 0
2015.11.22 14:17:08 5: FRM:>f076390000010000f7
2015.11.22 14:17:08 5: I2C_TSL2561_i2cwrite: Address 57 | Register 128
2015.11.22 14:17:08 5: I2C_TSL2561_Disable: end
2015.11.22 14:17:08 5: I2C_TSL2561_GetLuminosity: calc state 3 acqui state 0
2015.11.22 14:17:08 5: I2C_TSL2561_GetLuminosity: error, aborting
2015.11.22 14:17:08 1: PERL WARNING: Use of uninitialized value in multiplication (*) at ./FHEM/51_I2C_TSL2561.pm line 583.
2015.11.22 14:17:08 1: PERL WARNING: Use of uninitialized value in multiplication (*) at ./FHEM/51_I2C_TSL2561.pm line 584.
2015.11.22 14:17:08 5: I2C_TSL2561_Poll: 60 s
2015.11.22 14:17:08 5: FRM:<f07739000a015000f7
2015.11.22 14:17:08 5: --------------------------
2015.11.22 14:17:08 5: FRM: onI2CMessage address: '57', register: '138' data: [80]
2015.11.22 14:17:08 5: FRM: UPDATE Adresse: 57|Register: 138|Daten: 80
2015.11.22 14:17:08 5: FRM: UPDATE FRM_1_SENDSTAT => "Ok"
2015.11.22 14:17:08 5: Lichtsensor RX register 10, 1 byte: 80
2015.11.22 14:17:08 5: I2C_TSL2561_I2CRcvID: sensorId TSL2561 Package T/FN/CL Rev. 0


Orange ist der Lesevorgang, blau der Schreibvorgang, der inzwischen gestartet wird.

In diesem Beispiel läuft alles innerhalb einer Sekunde ab. Das lässt die Bandbreite der Kommunikationsdauer erahnen.

Warum willst Du blockieren? Was ist der Vorteil? Ich schreibe auf den I2C-Bus (hier bekomme ich keine Antwort) und schicke danach den Lesebefehl, und bekomme dann das Antwortpäckchen und kann prüfen ob's funktioniert hat.

jensb

ZitatWarum willst Du blockieren? Was ist der Vorteil?
Der gesamte vorhandene Ablauf ist sequentiell und die Blockierung in i2cread/write stellt sicher, das sich nichts überholt, wie das derzeit der Fall ist. Der 1. I2C-Zugriff muss erst beendet sein, bevor der nächste I2C-Zugriff starten kann, denn ohne die Antwort auf die 1. Aktion zu kennen, kann man nicht die richtige nächste Frage stellen.

Hier eine weitere Testversion. Auf dem RPi klappt es mit der Blockierung zwischen i2cread/write und I2CRec über das neue internal Reading "i2cOpInProgress". Dieser Ansatz mit Warteschleife ist nicht schön, aber einen Versuch wert.

Jens
FHEM 6.1 - RPi 4 Raspbian 12 + PiTFT - OPi Zero Armbian 5.35
EnOcean - (W)LAN/Firmata: BMP180, TSL2561, SHT21, Heatronic 3, OBIS - WLAN/ESP8266: Gardena 1251, Zirkulationspumpe - RTL433: Oregon - Bluetooth - MQTT
Contributions: https://svn.fhem.de/trac/browser/trunk/fhem/contrib/jensb

thymjan

Im Log ist die Blockierung nicht nachvollziehbar:
2015.11.22 14:40:37 5: I2C_TSL2561_Poll: start
2015.11.22 14:40:37 5: I2C_TSL2561_GetLuminosity: calc state 0 acqui state 0
2015.11.22 14:40:37 5: I2C_TSL2561_GetLuminosity: starting new measurement
2015.11.22 14:40:37 5: I2C_TSL2561_Enable: start
2015.11.22 14:40:37 5: FRM: Kommunikation mit I2C ...
2015.11.22 14:40:37 5: FRM: auf I2C lesen ...
2015.11.22 14:40:37 5: FRM:>f07639080a010100f7
2015.11.22 14:40:37 5: FRM: Adresse: 57|Register: 138|1 byte(s)
2015.11.22 14:40:37 5: I2C_TSL2561_Enable: end
2015.11.22 14:40:37 5: I2C_TSL2561_Disable: start
2015.11.22 14:40:37 5: FRM: Kommunikation mit I2C ...
2015.11.22 14:40:37 5: FRM: auf I2C schreiben ...
2015.11.22 14:40:37 5: FRM: Adresse: 57|Register: 128|Wert: 0
2015.11.22 14:40:37 5: FRM:>f076390000010000f7
2015.11.22 14:40:37 5: I2C_TSL2561_Disable: end
2015.11.22 14:40:37 5: I2C_TSL2561_GetLuminosity: calc state 3 acqui state 0
2015.11.22 14:40:37 5: I2C_TSL2561_GetLuminosity: error, aborting
2015.11.22 14:40:37 1: PERL WARNING: Use of uninitialized value in multiplication (*) at ./FHEM/51_I2C_TSL2561.pm line 585.
2015.11.22 14:40:37 1: PERL WARNING: Use of uninitialized value in multiplication (*) at ./FHEM/51_I2C_TSL2561.pm line 586.
2015.11.22 14:40:37 5: I2C_TSL2561_Poll: 60 s
2015.11.22 14:40:38 5: FRM:<f07739000a015000f7
2015.11.22 14:40:38 5: --------------------------
2015.11.22 14:40:38 5: FRM: onI2CMessage address: '57', register: '138' data: [80]
2015.11.22 14:40:38 5: FRM: UPDATE Adresse: 57|Register: 138|Daten: 80
2015.11.22 14:40:38 5: FRM: UPDATE FRM_1_SENDSTAT => "Ok"
2015.11.22 14:40:38 5: Lichtsensor RX register 10, 1 byte: 80
2015.11.22 14:40:38 5: I2C_TSL2561_I2CRcvID: sensorId TSL2561 Package T/FN/CL Rev. 0

jensb

Werde bei mir mehr Logging einbauen und mich gleich wieder melden.
FHEM 6.1 - RPi 4 Raspbian 12 + PiTFT - OPi Zero Armbian 5.35
EnOcean - (W)LAN/Firmata: BMP180, TSL2561, SHT21, Heatronic 3, OBIS - WLAN/ESP8266: Gardena 1251, Zirkulationspumpe - RTL433: Oregon - Bluetooth - MQTT
Contributions: https://svn.fhem.de/trac/browser/trunk/fhem/contrib/jensb

jensb

Hier die letzte Version mit mehr Logging. Meine Vermutung ist, dass unter Firmata I2CRec bereits aufgerufen wird, bevor die Daten da sind und damit die Blockierung beendet. Mit dem zusätzlichen Logging müsste man das "sichtbar" machen können.
FHEM 6.1 - RPi 4 Raspbian 12 + PiTFT - OPi Zero Armbian 5.35
EnOcean - (W)LAN/Firmata: BMP180, TSL2561, SHT21, Heatronic 3, OBIS - WLAN/ESP8266: Gardena 1251, Zirkulationspumpe - RTL433: Oregon - Bluetooth - MQTT
Contributions: https://svn.fhem.de/trac/browser/trunk/fhem/contrib/jensb

thymjan

#53
Habe die Schrittweite etwas erhöht (Logging war vorher zu lang):
2015.11.22 15:16:25 5: I2C_TSL2561_Poll: start
2015.11.22 15:16:25 5: I2C_TSL2561_GetLuminosity: calc state 0 acqui state 0
2015.11.22 15:16:25 5: I2C_TSL2561_GetLuminosity: starting new measurement
2015.11.22 15:16:25 5: I2C_TSL2561_Enable: start
2015.11.22 15:16:25 4: Lichtsensor: I2C_TSL2561_i2cread: INIT i2cOpInProgress=3000
2015.11.22 15:16:25 5: FRM: Kommunikation mit I2C ...
2015.11.22 15:16:25 5: FRM: auf I2C lesen ...
2015.11.22 15:16:25 5: FRM:>f07639080a010100f7
2015.11.22 15:16:25 5: FRM: Adresse: 57|Register: 138|1 byte(s)
2015.11.22 15:16:25 4: Lichtsensor: I2C_TSL2561_i2cread: START i2cOpInProgress=3000
2015.11.22 15:16:25 4: Lichtsensor: I2C_TSL2561_i2cread: LOOP i2cOpInProgress=2000
2015.11.22 15:16:25 4: Lichtsensor: I2C_TSL2561_i2cread: LOOP i2cOpInProgress=1000
2015.11.22 15:16:25 4: Lichtsensor: I2C_TSL2561_i2cread: LOOP i2cOpInProgress=0
2015.11.22 15:16:25 4: Lichtsensor: I2C_TSL2561_i2cread: END i2cOpInProgress=0
2015.11.22 15:16:25 5: I2C_TSL2561_Enable: end
2015.11.22 15:16:25 5: I2C_TSL2561_Disable: start
2015.11.22 15:16:25 4: Lichtsensor: I2C_TSL2561_i2cwrite: INIT i2cOpInProgress=3000
2015.11.22 15:16:25 5: FRM: Kommunikation mit I2C ...
2015.11.22 15:16:25 5: FRM: auf I2C schreiben ...
2015.11.22 15:16:25 5: FRM: Adresse: 57|Register: 128|Wert: 0
2015.11.22 15:16:25 5: FRM:>f076390000010000f7
2015.11.22 15:16:25 4: Lichtsensor: I2C_TSL2561_i2cwrite: START i2cOpInProgress=3000
2015.11.22 15:16:25 4: Lichtsensor: I2C_TSL2561_i2cwrite: LOOP i2cOpInProgress=2000
2015.11.22 15:16:25 4: Lichtsensor: I2C_TSL2561_i2cwrite: LOOP i2cOpInProgress=1000
2015.11.22 15:16:25 4: Lichtsensor: I2C_TSL2561_i2cwrite: LOOP i2cOpInProgress=0
2015.11.22 15:16:25 4: Lichtsensor: I2C_TSL2561_i2cwrite: END i2cOpInProgress=0
2015.11.22 15:16:25 5: I2C_TSL2561_Disable: end
2015.11.22 15:16:25 5: I2C_TSL2561_GetLuminosity: calc state 3 acqui state 0
2015.11.22 15:16:25 5: I2C_TSL2561_GetLuminosity: error, aborting
2015.11.22 15:16:25 1: PERL WARNING: Use of uninitialized value in multiplication (*) at ./FHEM/51_I2C_TSL2561.pm line 585.
2015.11.22 15:16:25 1: PERL WARNING: Use of uninitialized value in multiplication (*) at ./FHEM/51_I2C_TSL2561.pm line 586.
2015.11.22 15:16:25 5: I2C_TSL2561_Poll: 60 s
2015.11.22 15:16:25 5: FRM:<f07739000a015000f7
2015.11.22 15:16:25 5: --------------------------
2015.11.22 15:16:25 5: FRM: onI2CMessage address: '57', register: '138' data: [80]
2015.11.22 15:16:25 5: FRM: UPDATE Adresse: 57|Register: 138|Daten: 80
2015.11.22 15:16:25 5: FRM: UPDATE FRM_1_SENDSTAT => "Ok"
2015.11.22 15:16:25 5: Lichtsensor RX register 10, 1 byte: 80
2015.11.22 15:16:25 5: I2C_TSL2561_I2CRcvID: sensorId TSL2561 Package T/FN/CL Rev. 0
2015.11.22 15:16:25 4: Lichtsensor: I2C_TSL2561_I2CRec: END

thymjan

#54
FRM scheint erst gestartet zu werden und eine Antwort zu geben, nachdem Poll am Ende ist?

Bildlich gesprochen kann ich an einem Arbeitsplatz (in einer Funktion) entweder nur Briefe verschicken oder Briefe öffnen und Entscheidungen treffen.

Der Dreh- und Angelpunkt für die Entscheidungen ist hier die I2CRec-Funktion.
Hier werden die entsprechenden Unterfunktionen aufgerufen, die dann weitere "Briefe" verschicken dürfen.

jensb

Der Countdown läuft in 1000-Schritten statt in 20-Schritten und damit viel zu schnell:
Zitat
2015.11.22 15:16:25 4: Lichtsensor: I2C_TSL2561_i2cread: START i2cOpInProgress=3000
2015.11.22 15:16:25 4: Lichtsensor: I2C_TSL2561_i2cread: LOOP i2cOpInProgress=2000

Bitte ersetzte in i2cread/write versuchsweise

      $hash->{i2cOpInProgress} -= 20;

mit

      $hash->{i2cOpInProgress} = $hash->{i2cOpInProgress} - 20;


ZitatFRM scheint erst gestartet zu werden und eine Antwort zu geben, nachdem Poll am Ende ist?
Darauf müssen wir möglicherweise noch einmal zurück kommen.
FHEM 6.1 - RPi 4 Raspbian 12 + PiTFT - OPi Zero Armbian 5.35
EnOcean - (W)LAN/Firmata: BMP180, TSL2561, SHT21, Heatronic 3, OBIS - WLAN/ESP8266: Gardena 1251, Zirkulationspumpe - RTL433: Oregon - Bluetooth - MQTT
Contributions: https://svn.fhem.de/trac/browser/trunk/fhem/contrib/jensb

thymjan

In gekürzter Form, das Forum lässt so lange Posts nicht zu:
2015.11.22 15:11:38 5: I2C_TSL2561_Poll: start
2015.11.22 15:11:38 5: I2C_TSL2561_GetLuminosity: calc state 0 acqui state 0
2015.11.22 15:11:38 5: I2C_TSL2561_GetLuminosity: starting new measurement
2015.11.22 15:11:38 5: I2C_TSL2561_Enable: start
2015.11.22 15:11:38 4: Lichtsensor: I2C_TSL2561_i2cread: INIT i2cOpInProgress=3000
2015.11.22 15:11:38 5: FRM: Kommunikation mit I2C ...
2015.11.22 15:11:38 5: FRM: auf I2C lesen ...
2015.11.22 15:11:38 5: FRM:>f07639080a010100f7
2015.11.22 15:11:38 5: FRM: Adresse: 57|Register: 138|1 byte(s)
2015.11.22 15:11:38 4: Lichtsensor: I2C_TSL2561_i2cread: START i2cOpInProgress=3000
2015.11.22 15:11:38 4: Lichtsensor: I2C_TSL2561_i2cread: LOOP i2cOpInProgress=2980
2015.11.22 15:11:38 4: Lichtsensor: I2C_TSL2561_i2cread: LOOP i2cOpInProgress=2960
[...]
2015.11.22 15:11:39 4: Lichtsensor: I2C_TSL2561_i2cread: LOOP i2cOpInProgress=80
2015.11.22 15:11:39 4: Lichtsensor: I2C_TSL2561_i2cread: LOOP i2cOpInProgress=60
2015.11.22 15:11:39 4: Lichtsensor: I2C_TSL2561_i2cread: LOOP i2cOpInProgress=40
2015.11.22 15:11:39 4: Lichtsensor: I2C_TSL2561_i2cread: LOOP i2cOpInProgress=20
2015.11.22 15:11:39 4: Lichtsensor: I2C_TSL2561_i2cread: LOOP i2cOpInProgress=0
2015.11.22 15:11:39 4: Lichtsensor: I2C_TSL2561_i2cread: END i2cOpInProgress=0
2015.11.22 15:11:39 5: I2C_TSL2561_Enable: end
2015.11.22 15:11:39 5: I2C_TSL2561_Disable: start
2015.11.22 15:11:39 4: Lichtsensor: I2C_TSL2561_i2cwrite: INIT i2cOpInProgress=3000
2015.11.22 15:11:39 5: FRM: Kommunikation mit I2C ...
2015.11.22 15:11:39 5: FRM: auf I2C schreiben ...
2015.11.22 15:11:39 5: FRM: Adresse: 57|Register: 128|Wert: 0
2015.11.22 15:11:40 5: FRM:>f076390000010000f7
2015.11.22 15:11:40 4: Lichtsensor: I2C_TSL2561_i2cwrite: START i2cOpInProgress=3000
2015.11.22 15:11:40 4: Lichtsensor: I2C_TSL2561_i2cwrite: LOOP i2cOpInProgress=2980
2015.11.22 15:11:40 4: Lichtsensor: I2C_TSL2561_i2cwrite: LOOP i2cOpInProgress=2960
2015.11.22 15:11:40 4: Lichtsensor: I2C_TSL2561_i2cwrite: LOOP i2cOpInProgress=2940
[...]
2015.11.22 15:11:40 4: Lichtsensor: I2C_TSL2561_i2cwrite: LOOP i2cOpInProgress=20
2015.11.22 15:11:40 4: Lichtsensor: I2C_TSL2561_i2cwrite: LOOP i2cOpInProgress=0
2015.11.22 15:11:40 4: Lichtsensor: I2C_TSL2561_i2cwrite: END i2cOpInProgress=0
2015.11.22 15:11:41 5: I2C_TSL2561_Disable: end
2015.11.22 15:11:41 5: I2C_TSL2561_GetLuminosity: calc state 3 acqui state 0
2015.11.22 15:11:41 5: I2C_TSL2561_GetLuminosity: error, aborting
2015.11.22 15:11:41 1: PERL WARNING: Use of uninitialized value in multiplication (*) at ./FHEM/51_I2C_TSL2561.pm line 585.
2015.11.22 15:11:41 1: PERL WARNING: Use of uninitialized value in multiplication (*) at ./FHEM/51_I2C_TSL2561.pm line 586.
2015.11.22 15:11:41 5: I2C_TSL2561_Poll: 60 s
2015.11.22 15:11:41 5: FRM:<f07739000a015000f7
2015.11.22 15:11:41 5: --------------------------
2015.11.22 15:11:41 5: FRM: onI2CMessage address: '57', register: '138' data: [80]
2015.11.22 15:11:41 5: FRM: UPDATE Adresse: 57|Register: 138|Daten: 80
2015.11.22 15:11:41 5: FRM: UPDATE FRM_1_SENDSTAT => "Ok"
2015.11.22 15:11:41 5: Lichtsensor RX register 10, 1 byte: 80
2015.11.22 15:11:41 5: I2C_TSL2561_I2CRcvID: sensorId TSL2561 Package T/FN/CL Rev. 0
2015.11.22 15:11:41 4: Lichtsensor: I2C_TSL2561_I2CRec: END

jensb

Zitat
Der Dreh- und Angelpunkt für die Entscheidungen ist hier die I2CRec-Funktion.
Hier werden die entsprechenden Unterfunktionen aufgerufen, die dann weitere "Briefe" verschicken dürfen.

Beim BMP180-Modul ist das so, aber der TSL2561-Sensor ist da anspruchsvoller. Hier sind aufgrund der Einstellvorgänge mehrere I2C-Operationen hintereinander auszuführen, um das gewünschte Ergebnis zu erreichen, also z.B. Enable + Low-Data + Hi-Data + Disable. Das wird von I2C_TSL2561_GetData koordiniert.
FHEM 6.1 - RPi 4 Raspbian 12 + PiTFT - OPi Zero Armbian 5.35
EnOcean - (W)LAN/Firmata: BMP180, TSL2561, SHT21, Heatronic 3, OBIS - WLAN/ESP8266: Gardena 1251, Zirkulationspumpe - RTL433: Oregon - Bluetooth - MQTT
Contributions: https://svn.fhem.de/trac/browser/trunk/fhem/contrib/jensb

jensb

Das Logging zeigt, das beim Warten keine Zeit vergeht. Aber das ist hoffentlich nicht wirklich so sondern mein Versehen. usleep braucht Mikrosekunden und nicht Millisekunden. Bitte vergrößere in i2cread/write den Startwert von 3000 auf 3000000.
FHEM 6.1 - RPi 4 Raspbian 12 + PiTFT - OPi Zero Armbian 5.35
EnOcean - (W)LAN/Firmata: BMP180, TSL2561, SHT21, Heatronic 3, OBIS - WLAN/ESP8266: Gardena 1251, Zirkulationspumpe - RTL433: Oregon - Bluetooth - MQTT
Contributions: https://svn.fhem.de/trac/browser/trunk/fhem/contrib/jensb

thymjan

Dann kann ich doch die Briefe in Reihe
Enable(write) + broadband(read) + ir(read) + Disable(write)
abschicken, und habe dann am I2CRec-"Schreibtisch" zunächst den Brief broadband und dann ir zum Lesen und Entscheiden vorliegen. Nun gut, dass sind dann 2 I2CRec-Schreibtischsitzungen... die liegen nicht zur selben Zeit vor.