deviceInit('/dev/ttyGW',9600,'none',8,2,'none'); //print_r($modbus); //sleep(9); // Open port $modbus->deviceOpen(); //print_r($modbus); //sleep(9); // Enable debug $modbus->debug = $debug; # read registers 0-162 $regnos = array(); #Register Numbers 0-162 $startingaddress = str_pad(dechex(16), 4, "0", STR_PAD_LEFT); echo "\n$startingaddress\n"; echo "starting address = $startingaddress \n"; $Numberofpoints = str_pad(dechex(15), 4, "0", STR_PAD_LEFT); echo "\n$Numberofpoints\n"; $result=$modbus->sendQuery(1,3,"$startingaddress", 15); if($debug) print_r($result); //print ("1,3,$startingaddress,15"); //print_r($result); //sleep(9); for($i=0; $i < 30; $i+=2) { $j = $i+1; echo $i/2+16, '
Word = ', $result[$i] . $result[$j], chr(10); $regnos[] = $result[$i] . $result[$j]; } //echo "print_r regnos"; //print_r($regnos); $modbus->deviceClose(); ?>