protected function readTempData($device)
{
- $value = @file_get_contents('/sys/bus/w1/devices/'.$device.'/temperature');
- if ($value === FALSE)
+ for ($try = 0; $try <3; $try++)
{
- return FALSE;
+ $value = @file_get_contents('/sys/bus/w1/devices/'.$device.'/w1_slave');
+ if ($value === FALSE)
+ {
+ continue;
+ }
+ $C = preg_match('/.*crc=..\s(.*)\n.*t=(.*)\n/m', $value, $match);
+ if ($C == 0)
+ {
+ continue;
+ }
+ if ($match[1] != 'YES')
+ {
+ continue;
+ }
+ $result = $match[2];
+ break;
+ }
+ if (isset($result))
+ {
+ return $result;
+ }
+ else
+ {
+ return false;
}
- return $value;
}
protected function ChildBody($data)
foreach ($DEVS as $DEV)
{
- $DATA[$DEV] = $this->readTempData($DEV);
-
+ $RDATA = $this->readTempData($DEV);
+ if ($RDATA !== false)
+ {
+ $DATA[$DEV] = $this->readTempData($DEV);
+ }
}
$SR = $this->SendEvent('data', $DATA);
sleep(30);