Web lists-archives.com

[PHP] PHP extension writing




Hello

i try to write a php extension for raspberry to get i2c data.
This is my first extension. And maybe not the corect mailing list.

The Problem, on the CLI I get the correct return value.
If i run the same code in an webbrowser i got a wrong value.

PHP_FUNCTION(i2c_read_value)
{
    int arg_len;
    unsigned char reg;
    unsigned short res;

    if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &reg,
&arg_len) == FAILURE){
        RETURN_FALSE;
    }

    res = i2c_smbus_read_byte_data(dev_fd, reg);

    RETURN_LONG(res);
}


if i run these code in CLI 
<?php

i2c_init(1,0x48,0);
echo i2c_read_value(0x40);
i2c_close();

?>

php i2c.php 

i get 49 these comes from an ADC and the range is 0 - 255. In an C
programm i get the same value.

wenn I run the script in an browser i get: 65535

someone can give me a hint ?


BR/Torsten 








-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php