Wenn dies dein erster Besuch hier ist, lies bitte zuerst die Hilfe - Häufig gestellte Fragen durch. Du musst dich vermutlich registrieren, bevor du Beiträge verfassen kannst. Klicke oben auf 'Registrieren', um den Registrierungsprozess zu starten. Du kannst auch jetzt schon Beiträge lesen. Suche dir einfach das Forum aus, das dich am meisten interessiert.
You can also replace it by require_once('eibclient.php'); to be sure it doesn't try to include it multiple times.
I've streamlined the code a bit and put "require_once" everywhere I could (even where it doesn't make sense )
I works
I have a (almost) decent Visu on the phone now.
send.php contains code for sending. If you want to adapt the application to your installation, you need to modify config.php.
OK, I might resort to this solution if I get stuck. But I'm a bit reluctant as the interface with the Cisco phone isn't very easy and my application is almost finished (besides refreshing the KNX status to display the current icone)
From the error message you receive, I would say that the second parameter of GroupRead function doesn't contain a correctly formatted group address.
There is no reason to suspect the parameter, as it is the same used in the first call.... until I realize I've made a big mistake
The second call to GroupRead is issued from within another function and I thought the parameters are inherited from the main script. Not true in PHP.
I declared the variables as "global" within the calling function, but then I got again the original error messages.
So I applied again both of your previous suggestions, no luck. The original error message is back again:
PHP Fatal error: Cannot redeclare class EIBBuffer in /usr/share/php5/eib
client.php on line 28
This happens when I add a second call to GroupRead, like:
$MyStat=GroupRead("127.0.0.1",$ga2);
Hi,
From the error message you receive, I would say that the second parameter of GroupRead function doesn't contain a correctly formatted group address. This parameter must contain a group address with the format "x/y/z".
The message "Undefined offset: 1 in /usr/share/php5/GroupRead.php on line 8" says that the second parameter doesn't contain any '/' character.
The message "Undefined offset: 2 in /usr/share/php5/GroupRead.php on line 8" says that the second parameter only contains one '/' character.
Just add a print("GA: $ga2"); before the call to GroupRead and you will see what's wrong.
But would you be so kind to point me to a description of the expected params ?
First parameter is an EIBD connection
Code:
$connection = new EIBConnection("hostname");
// If you don't have enabled Group Cache (eg. with EIBD command line switch), you need to enable
$connection->EIB_Cache_Enable ();
The connection can be used in all parts of your script. The second parameter is the group address (eg. "1/1/1"). The third parameter $age is a little bit more complex.
Let me first start with the function of group cache: It keeps the last telegram for all group addresses, so that you can query the state of a group object without any delay. If there isn't any value for a group object, EIBD request it via A_GroupValue_Read.
To simplify the interface, EIBD has no knowlege about the objects. It is the responsibility of the application to know, if a group object is suitable for querying. Eg: EIBD will provide you the last value of a up/down dimmer button, although it does not make any sense.
$age provides greater control over the result. if it is 0, you get the last cached value. Else: It provides the last cached value, if its not older than $age seconds. If its older than $age, it requests a new value from the bus.
In many cases 0 should work. A age > 0 can be used to reduce bus load.
For interpreting the result (errors!!), please look at fetchstats in contrib/eibdvis/layout.php. It decodes the 3 error codes. Otherwise it returns the raw value. elements.php contains code to interpret this value for some common devices.
send.php contains code for sending. If you want to adapt the application to your installation, you need to modify config.php. It creates containers ("rooms") and puts devices into them. Look at the _construct functions in elements.php for the parameter for the various devices. The first addresses ($*addr) contain the group addresses for sending telegrams to. Then the addresses for querying the state ($*stateaddr) follow. In simple installation both can be the same group address. $*age can be used the control the fetch interval.
PHP Fatal error: Cannot redeclare class EIBBuffer in /usr/share/php5/eibclient.php on line 28
This happens when I add a second call to GroupRead, like:
$MyStat=GroupRead("127.0.0.1",$ga2);
NB: Obviously, I didn't touch the eibclient.php
Removing the second instance cures the problem, this makes me think I'm performing something illegal, like reading from a closed port, or opening something already open etc
The only thing I see is to move the require('eibclient.php'); line outside of the function. (at the beginning of the file, for example). You can also replace it by require_once('eibclient.php'); to be sure it doesn't try to include it multiple times.
It seems that it's not allowed to call the "groupread" function several times in the the same script, probably due to some initialization stuff that should only happen once.
Try switching to the group cache (EIB_Cache_Read_Sync). Then EIBD will do the whole thing for you.
For an example look at function cacheread in contrib/eibdvis/help.php, BCU SDK sources.
I tried to write a couple of examples with the php interface to see how it works.
groupread.php
Hi,
It seems that it's not allowed to call the "groupread" function several times in the the same script, probably due to some initialization stuff that should only happen once.
Pointing me to a piece of PHP code, with a practical example of the client library usage would be appreciated, especially the syntax of using a BCU1.
So far, I've only found PHP samples making use of IP.
I hope, you have noticed contrib/eibdvis in the BCU SDK sources. It is my PHP demo for our demonstation system.
The code above is a concatenation of the previous value of "$return" (here -1) with $buf[$i] which contains the next byte of the message received from bus (here 124).
As you discovered it, 124 is the dimmer status value with 0=0% and 255=100% . (124 * 100/255 = 48,6 ~= 49)
$con->EIBClose();
return $return; // return the EIB status, 0=Off, 1=On, xx-dimmer value
}
?>
Could you post more code? Especially to explain what you do with variable $return before returning it. How do you "cast the return code to a single byte" ?
Wir verarbeiten personenbezogene Daten über die Nutzer unserer Website mithilfe von Cookies und anderen Technologien, um unsere Dienste bereitzustellen. Weitere Informationen findest Du in unserer Datenschutzerklärung.
Indem Du unten auf "ICH stimme zu" klickst, stimmst Du unserer Datenschutzerklärung und unseren persönlichen Datenverarbeitungs- und Cookie-Praktiken zu, wie darin beschrieben. Du erkennst außerdem an, dass dieses Forum möglicherweise außerhalb Deines Landes gehostet wird und bist damit einverstanden, dass Deine Daten in dem Land, in dem dieses Forum gehostet wird, gesammelt, gespeichert und verarbeitet werden.
Einen Kommentar schreiben: