Re: [PHP] I2C and PHP

[email protected] (Per Jessen)
Newsgroups php.general
Organization Per Jessens personal news-server
Message-ID <[email protected]>
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)
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.