|
|
@ -19,17 +19,19 @@ Features |
|
|
|
Example |
|
|
|
Example |
|
|
|
------- |
|
|
|
------- |
|
|
|
|
|
|
|
|
|
|
|
// Modbus master UDP |
|
|
|
```php |
|
|
|
$modbus = new ModbusMaster("192.168.1.1", "UDP"); |
|
|
|
// Modbus master UDP |
|
|
|
// Read multiple registers |
|
|
|
$modbus = new ModbusMaster("192.168.1.1", "UDP"); |
|
|
|
try { |
|
|
|
// Read multiple registers |
|
|
|
$recData = $modbus->readMultipleRegisters(0, 12288, 5); |
|
|
|
try { |
|
|
|
} |
|
|
|
$recData = $modbus->readMultipleRegisters(0, 12288, 5); |
|
|
|
catch (Exception $e) { |
|
|
|
} |
|
|
|
// Print error information if any |
|
|
|
catch (Exception $e) { |
|
|
|
echo $modbus; |
|
|
|
// Print error information if any |
|
|
|
echo $e; |
|
|
|
echo $modbus; |
|
|
|
exit; |
|
|
|
echo $e; |
|
|
|
} |
|
|
|
exit; |
|
|
|
// Print data in string format |
|
|
|
} |
|
|
|
echo PhpType::bytes2string($recData); |
|
|
|
// Print data in string format |
|
|
|
|
|
|
|
echo PhpType::bytes2string($recData); |
|
|
|
|
|
|
|
``` |
|
|
|