I'm no PHP expert, but I gather you are avoiding owphp entirely, building your PHP class by reading from the FUSE filesystem. That will certainly work, though permissions make take a bit of work.
Paul Alfille
On 7/27/06, Davin Thompson <[EMAIL PROTECTED]> wrote:
I had a heck of a time getting owphp to compile under gentoo... However, a
simple class in php seems to serve just as well! Its still a bit crude, i
havent worked it into the rest of my application yet, and im not so sure
about the writing to devices yet... other than that it works, and i thought
i'd share it for anyone else having simmilar difficulties.
oh.. and an important note: you need to start owfs witht he following:
/opt/owfs/bin/owfs -F -u /mnt/owfs/ --fuse-opt="\"$FUSEOPTS\""
<?
//Demo code loops through values
$ow = new OneWire;
foreach($ow->devices() as $device) {
echo $ow->write($device,"templow", 50.1);
foreach ($ow->abilities($device) as $value) {
echo "<b>".$device. " - ". $value . " </b>- " .
$ow->read($devi$
}
}
// And the actuall class
class OneWire {
var $owBaseDir="/mnt/owfs";
function OneWire(){
}
function devices() {
$dirlist = scandir($this->owBaseDir);
foreach ($dirlist as $entry) {
if (fnmatch("??.????????????",$entry)) {
$devices[]=$entry;
}
}
return $devices;
}
function temperature($device) {
$filename = $this->owBaseDir."/".$device."/temperature";
if (file_exists($filename)) {
$file = fopen($filename, "r");
$value = fread($file, 1024);
fclose($file);
return $value;
}
}
function abilities($device) {
$path = $this->owBaseDir."/".$device;
$dirlist = scandir($path);
foreach ($dirlist as $entry) {
switch ($entry) {
case "temperature":
case "type":
case "family":
case "ID":
case "temphigh":
case "templow":
case "address":
$ability[]=$entry;
break;
default:
//do nothing
}
}
return $ability;
}
function read($device, $value) {
$filename = $this->owBaseDir."/".$device."/".$value;
if (file_exists($filename)) {
$file = fopen($filename, "r");
$value = fread($file, 1024);
fclose($file);
return $value;
}
}
function write($device, $value, $data) {
$filename = $this->owBaseDir."/".$device."/".$value;
if (file_exists($filename)) {
$file = fopen($filename, "wb");
settype($data, "double");
echo "<br>debug: ". $data . "<br>";
if (fwrite($file, (double)$data) === FALSE) {
fclose($file);
return "WRITE ERROR";
}
fclose($file);
return "OK".$data."<br>";
}
}
}
?>
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Owfs-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/owfs-developers
------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________ Owfs-developers mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/owfs-developers
