PHP extension writing

From: Date: Sat, 24 Sep 2016 14:29:13 +0000
Subject: PHP extension writing
Groups: php.general 
Request: Send a blank email to php-general+get-325741@lists.php.net to get a copy of this message
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

« previous php.general (#325741) next »