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