Re: I2C and PHP
| From: | Per Jessen | Date: | Tue, 16 Jun 2009 08:09:13 +0000 |
| Subject: | Re: I2C and PHP | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-294065@lists.php.net to get a copy of this message | ||
Tobias Krieger wrote:
> So, what I need is a way to convert any value between 0 and 255 into a
> string with one byte, e.g
>
> 0xff = 1111 1111 (with strlen($data) == 1)
>
> I tried it with:
>
> chr(255) - not successfull
> pack("H" and "h", 0xff) - not successfull
> decbin(255) - without success
>
> And many more variations....
> Any ideas, suggestions, .... Thanks!
I tried the following:
$d=chr(255);
$f=fopen('klop','w');
fwrite($f,$d);
fclose($f);
The produces a file called 'klop' containing exactly one byte = 0xFF.
That should work with your /dev/i2c interface as well - if not,
something else is getting in your way.
/Per
--
Per Jessen, Zürich (16.9°C)