It is a PHP Extension for Modbus RTU
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
tests
CREDITS
LICENSE
README.md
config.m4
config.w32
functions.c
modbus.c
modbus.h
modbus.php
php_modbus.h
serial.c
serial.h

README.md

PHP-Extension-Modbus

Master functions

modbus_open

modbus_open(string $port, int $baud_rate, char $parity, int $bit_stop, int $time_out);
return PORT reference
example: $port = modbus_open("/dev/ttyUSB0", 38400, "N", 2, 50);

modbus_close

use : modbus_close(ref $port);
$port = reference of modbus_open call

modbus_read_holding_registers

use : $v = modbus_read_holding_registers(ref $port, int $id_slave, int $register, int $n_read);
$port = reference of modbus_open call
$id_slave = number Id Node of the slave device
$register = Register number start to read
$n_read = how many registers reads (started from $register)

example:
$v = modbus_read_holding_registers($port, 28, 215, 4); // read registers: 215, 216, 217 and 218

modbus_read_input_registers

use : $v = modbus_read_input_registers(ref $port, int $id_slave, int $register, int $n_read);
read above

modbus_write

$r = modbus_write(int port, unsigned int device, unsigned int add, unsigned int len, unsigned int *dataw);
(Need to improve it)