Re: PHP extension writing

From: Date: Sat, 24 Sep 2016 15:46:46 +0000
Subject: Re: PHP extension writing
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-325742@lists.php.net to get a copy of this message
On 24.09.2016 at 16:29, Torsten Rosenberger wrote: > 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){ That looks wrong. reg should be declared as char *. > RETURN_FALSE; > } > > res = i2c_smbus_read_byte_data(dev_fd, reg); Where is dev_fd defined and initialized? > 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 ? There might be a permission or working directory issue. -- Christoph M. Becker

« previous php.general (#325742) next »