I am running an owserver process on SUSE linux 9.2 using a USB interface (DS9490)

I am talking to a DS1921G thermocron (bought the development kit from Dallas).

I was looking at the temperature using owhttpd (with -F).  E.g, I'd look at
http://localhost:8002/21.CE8E14000000/temperature and the value would be something like 77 degrees.
I was  writing a perl script to collect the same data and so I have the following in the script:

#!/usr/bin/perl -I/opt/owfs/bin/

use OW;

my $o = OW::init("localhost:8001");

my $x = OW::get("/21.CE8E14000000/temperature");

print $x;

The value I got was around 25.  Hm, I thought, perhaps a problem with no fahrenheit switch, so I did the conversion with a calculator, and it was a little off of what the owhttpd was reporting.  So, I reloaded the page in the browser (mozilla/firefox).  I was surprised to see that the browser now reports the temperature in centigrade as well.

I am unsure if there is a way to pass arguments to OW::init to make it read in fahrenheight.

A second question is how can I enumerate the devices available from the perl script, so that I can collect all of the termperatures there are? - wait I figured that out.  Here's a way to get all the devices which have a 'temperature' entry in them:
#!/usr/bin/perl -I/opt/owfs/bin/

use OW;
my $o = OW::init("localhost:8001");
my @directories = split(/,/, OW::get("/"));
$#directories -= 2; # remove 'alarm/' and 'simultaneous/'
@temps = map($_ . ":" . OW::get($_."temperature"),
         @directories); # Get temperatures
@temps = grep(!/:$/, @temps); # Remove non-temperature devices

print join("\n", @temps), "\n";

Reply via email to