2011-04-13 222 views
0

我運行它調用其他程序的functions.php一個PHP程序control.php但有一個錯誤 我的程序給出如下致命錯誤

CONTROL.PHP

$sleeptime = 125000; 
require("functions.php"); 

$temp = $_SERVER['argv'][1]; 
if (is_numeric($temp)) { 
    if ($temp >= 66 && $temp <= 88) { 
     echo "Setting temperature to {$temp}F...\n"; 
     flush(); 
     usleep($sleeptime); 
     reset_ac(); 
     $up = $temp - 66; 
     updeg($up); 
     echo "Done.\n"; 



    } else { 
     echo "Temperature must be a number between 66 and 88!\n"; 
    } 
} else { 
    echo "Temperature must be a number!\n"; 
} 

的functions.php

//relay control board functions 
$relay['ip'] = "192.168.10.180"; 
$relay['read'] = "public"; 
$relay['write'] = "private"; 
$relay['base'] = ".1.3.6.1.4.1.19865.1.2."; 
$relay['base'] = ".1.3.6.1.4.1.19865.1.2."; 

$relay['num'][1] = "1.1.0"; 
$relay['num'][2] = "1.2.0"; 
$relay['num'][3] = "1.3.0"; 
$relay['num'][4] = "1.4.0"; 
$relay['num'][5] = "1.5.0"; 
$relay['num'][6] = "1.6.0"; 
$relay['num'][7] = "1.7.0"; 
$relay['num'][8] = "1.8.0"; 
$relay['num'][9] = "2.1.0"; 
$relay['num'][10] = "2.2.0"; 
$relay['num'][11] = "2.3.0"; 
$relay['num'][12] = "2.4.0"; 
$relay['num'][13] = "2.5.0"; 
$relay['num'][14] = "2.6.0"; 
$relay['num'][15] = "2.7.0"; 
$relay['num'][16] = "2.8.0"; 
$relay['num'][17] = "3.1.0"; 
$relay['num'][18] = "3.2.0"; 
$relay['num'][19] = "3.3.0"; 
$relay['num'][20] = "3.4.0"; 
$relay['num'][21] = "3.5.0"; 
$relay['num'][22] = "3.6.0"; 
$relay['num'][23] = "3.7.0"; 
$relay['num'][24] = "3.8.0"; 

//returns the value of the specified relay 
function getrelay($val) { 
    global $relay; 
    $data = snmpget($relay['ip'],$relay['read'],"{$relay['base']}{$relay['num'][$val]}"); 
    return $data; 
} 

//sets a specified relay on or off 
function setrelay($val, $val2) { 
    global $relay; 
    $data = snmpset($relay['ip'],$relay['write'],"{$relay['base']}{$relay['num'][$val]}","i","$val2","0"); 
    return $data; 
} 

//resets all relays to off 
function clear() { 
    for ($a = 1; $a <= 16; $a++) { 
     setrelay($a, 0); 
    } 
} 

function reset_ac() { 
    global $sleeptime; 
    echo "Resetting to 66F"; 
    for ($a = 1; $a <= 22; $a++) { 
     setrelay(1,1); 
     echo "."; 

     flush(); 
     usleep($sleeptime); 
     setrelay(1,0); 

     flush(); 
     usleep($sleeptime); 
    } 
    echo " Done.\n"; 
} 

function updeg($deg) { 
    global $sleeptime; 
    echo "Stepping up {$deg}F"; 
    for ($a = 1; $a <= $deg; $a++) { 
     setrelay(2,1); 
     echo "."; 

     flush(); 
     usleep($sleeptime); 
     setrelay(2,0); 

     flush(); 
     usleep($sleeptime); 
    } 
    echo " Done.\n"; 
} 

function downdeg($deg) { 
    global $sleeptime; 
    echo "Stepping up {$deg}F"; 
    for ($a = 1; $a <= $deg; $a++) { 
     setrelay(1,1); 
     echo "."; 

     flush(); 
     usleep($sleeptime); 
     setrelay(1,0); 

     flush();   
     usleep($sleeptime); 
    } 
    echo " Done.\n"; 
} 

的誤差表示作爲致命錯誤:無法定義上線snmpset()在/root/functions.php 44

請幫

+0

這不是整個錯誤消息。它告訴你在哪個行號出現,以及函數之前聲明的位置。如果兩者都是相同的,那麼你只是包括一個腳本兩次。 – mario 2011-04-13 06:07:19

+0

您是否檢查過安裝中是否啓用了SNMP支持? – JohnP 2011-04-13 06:10:33

+0

我在linux中這樣做...我需要安裝snmp支持嗎?如果是,那麼如何? – 2011-04-13 06:56:53

回答