Class ModbusMaster

Description

ModbusMaster

This class deals with the MODBUS master

Implemented MODBUS master functions:

  • FC 1: read coils
  • FC 2: read input discretes
  • FC 3: read multiple registers
  • FC 4: read multiple input registers
  • FC 5: write single coil
  • FC 6: write single register
  • FC 15: write multiple coils
  • FC 16: write multiple registers
  • FC 23: read write registers

  • author: Jan Krakora
  • copyright: Copyright (c) 2004, 2013 Jan Krakora

Located in /Phpmodbus/ModbusMaster.php (line 42)


	
			
Direct descendents
Class Description
ModbusMasterTcp ModbusMasterTcp
ModbusMasterUdp ModbusMasterUdp
Variable Summary
mixed $client
mixed $client_port
mixed $endianness
mixed $host
mixed $port
mixed $status
mixed $timeout_sec
Method Summary
ModbusMaster ModbusMaster (String $host, String $protocol)
type fc1 (type $unitId, type $reference, type $quantity)
type fc2 (type $unitId, type $reference, type $quantity)
false|Array fc3 (int $unitId, int $reference, int $quantity)
false|Array fc4 (int $unitId, int $reference, int $quantity)
bool fc5 (int $unitId, int $reference, array $data, array $dataTypes)
bool fc6 (int $unitId, int $reference, array $data, array $dataTypes)
bool fc15 (int $unitId, int $reference, array $data)
bool fc16 (int $unitId, int $reference, array $data, array $dataTypes)
false|Array fc23 (int $unitId, int $referenceRead, int $quantity, int $referenceWrite, array $data, array $dataTypes)
void readCoils (type $unitId, type $reference, type $quantity)
void readInputDiscretes (type $unitId, type $reference, type $quantity)
false|Array readMultipleInputRegisters (int $unitId, int $reference, int $quantity)
false|Array readMultipleRegisters (int $unitId, int $reference, int $quantity)
false|Array readWriteRegisters (int $unitId, int $referenceRead, int $quantity, int $referenceWrite, array $data, array $dataTypes)
type writeMultipleCoils (type $unitId, type $reference, type $data)
bool writeMultipleRegister (int $unitId, int $reference, array $data, array $dataTypes)
bool writeSingleCoil (int $unitId, int $reference, array $data)
bool writeSingleRegister (int $unitId, int $reference, array $data, array $dataTypes)
void __toString ()
Variables
mixed $client = "" (line 46)
  • access: public
mixed $client_port = "502" (line 47)
  • access: public
mixed $endianness = 0 (line 50)
  • access: public
mixed $host = "192.168.1.1" (line 44)
  • access: public
mixed $port = "502" (line 45)
  • access: public
mixed $socket_protocol = "UDP" (line 51)
  • access: public
mixed $status (line 48)
  • access: public
mixed $timeout_sec = 5 (line 49)
  • access: public
Methods
Constructor ModbusMaster (line 61)

ModbusMaster

This is the constructor that defines $host IP address of the object.

ModbusMaster ModbusMaster (String $host, String $protocol)
  • String $host: An IP address of a Modbus TCP device. E.g. "192.168.1.1"
  • String $protocol: Socket protocol (TCP, UDP)
fc1 (line 255)

fc1

Alias to readCoils method

type fc1 (type $unitId, type $reference, type $quantity)
  • type $unitId
  • type $reference
  • type $quantity
fc2 (line 370)

fc2

Alias to readInputDiscretes method

type fc2 (type $unitId, type $reference, type $quantity)
  • type $unitId
  • type $reference
  • type $quantity
fc3 (line 463)

fc3

Alias to readMultipleRegisters method.

false|Array fc3 (int $unitId, int $reference, int $quantity)
  • int $unitId
  • int $reference
  • int $quantity
fc4 (line 562)

fc4

Alias to readMultipleInputRegisters method.

false|Array fc4 (int $unitId, int $reference, int $quantity)
  • int $unitId
  • int $reference
  • int $quantity
fc5 (line 661)

fc5

Alias to writeSingleCoil method

bool fc5 (int $unitId, int $reference, array $data, array $dataTypes)
  • int $unitId
  • int $reference
  • array $data
  • array $dataTypes
fc6 (line 764)

fc6

Alias to writeSingleRegister method

bool fc6 (int $unitId, int $reference, array $data, array $dataTypes)
  • int $unitId
  • int $reference
  • array $data
  • array $dataTypes
fc15 (line 861)

fc15

Alias to writeMultipleCoils method

bool fc15 (int $unitId, int $reference, array $data)
  • int $unitId
  • int $reference
  • array $data
fc16 (line 982)

fc16

Alias to writeMultipleRegister method

bool fc16 (int $unitId, int $reference, array $data, array $dataTypes)
  • int $unitId
  • int $reference
  • array $data
  • array $dataTypes
fc23 (line 1103)

fc23

Alias to readWriteRegisters method.

false|Array fc23 (int $unitId, int $referenceRead, int $quantity, int $referenceWrite, array $data, array $dataTypes)
  • int $unitId
  • int $referenceRead
  • int $quantity
  • int $referenceWrite
  • array $data
  • array $dataTypes
readCoils (line 225)

readCoils

Modbus function FC 1(0x01) - Read Coils

Reads $quantity of Coils (boolean) from reference $reference of a memory of a Modbus device given by $unitId.

void readCoils (type $unitId, type $reference, type $quantity)
  • type $unitId
  • type $reference
  • type $quantity
readInputDiscretes (line 340)

readInputDiscretes

Modbus function FC 2(0x02) - Read Input Discretes

Reads $quantity of Inputs (boolean) from reference $reference of a memory of a Modbus device given by $unitId.

void readInputDiscretes (type $unitId, type $reference, type $quantity)
  • type $unitId
  • type $reference
  • type $quantity
readMultipleInputRegisters (line 532)

readMultipleInputRegisters

Modbus function FC 4(0x04) - Read Multiple Input Registers.

This function reads $quantity of Words (2 bytes) from reference $referenceRead of a memory of a Modbus device given by $unitId.

  • return: Success flag or array of received data.
false|Array readMultipleInputRegisters (int $unitId, int $reference, int $quantity)
  • int $unitId: usually ID of Modbus device
  • int $reference: Reference in the device memory to read data.
  • int $quantity: Amounth of the data to be read from device.
readMultipleRegisters (line 433)

readMultipleRegisters

Modbus function FC 3(0x03) - Read Multiple Registers.

This function reads $quantity of Words (2 bytes) from reference $referenceRead of a memory of a Modbus device given by $unitId.

  • return: Success flag or array of received data.
false|Array readMultipleRegisters (int $unitId, int $reference, int $quantity)
  • int $unitId: usually ID of Modbus device
  • int $reference: Reference in the device memory to read data (e.g. in device WAGO 750-841, memory MW0 starts at address 12288).
  • int $quantity: Amounth of the data to be read from device.
readWriteRegisters (line 1070)

readWriteRegisters

Modbus function FC23(0x17) - Read Write Registers.

This function writes $data array at reference $referenceWrite position of memory of a Modbus device given by $unitId. Simultanously, it returns $quantity of Words (2 bytes) from reference $referenceRead.

  • return: Success flag or array of data.
false|Array readWriteRegisters (int $unitId, int $referenceRead, int $quantity, int $referenceWrite, array $data, array $dataTypes)
  • int $unitId: usually ID of Modbus device
  • int $referenceRead: Reference in the device memory to read data (e.g. in device WAGO 750-841, memory MW0 starts at address 12288).
  • int $quantity: Amounth of the data to be read from device.
  • int $referenceWrite: Reference in the device memory to write data.
  • array $data: Array of values to be written.
  • array $dataTypes: Array of types of values to be written. The array should consists of string "INT", "DINT" and "REAL".
writeMultipleCoils (line 832)

writeMultipleCoils

Modbus function FC15(0x0F) - Write Multiple Coils

This function writes $data array at $reference position of memory of a Modbus device given by $unitId.

type writeMultipleCoils (type $unitId, type $reference, type $data)
  • type $unitId
  • type $reference
  • type $data
writeMultipleRegister (line 951)

writeMultipleRegister

Modbus function FC16(0x10) - Write Multiple Register.

This function writes $data array at $reference position of memory of a Modbus device given by $unitId.

  • return: Success flag
bool writeMultipleRegister (int $unitId, int $reference, array $data, array $dataTypes)
  • int $unitId: usually ID of Modbus device
  • int $reference: Reference in the device memory (e.g. in device WAGO 750-841, memory MW0 starts at address 12288)
  • array $data: Array of values to be written.
  • array $dataTypes: Array of types of values to be written. The array should consists of string "INT", "DINT" and "REAL".
writeSingleCoil (line 630)

writeSingleCoil

Modbus function FC5(0x05) - Write Single Register.

This function writes $data single coil at $reference position of memory of a Modbus device given by $unitId.

  • return: Success flag
bool writeSingleCoil (int $unitId, int $reference, array $data)
  • int $unitId: usually ID of Modbus device
  • int $reference: Reference in the device memory (e.g. in device WAGO 750-841, memory MW0 starts at address 12288)
  • array $data: value to be written (TRUE|FALSE).
writeSingleRegister (line 733)

writeSingleRegister

Modbus function FC6(0x06) - Write Single Register.

This function writes $data single word value at $reference position of memory of a Modbus device given by $unitId.

  • return: Success flag
bool writeSingleRegister (int $unitId, int $reference, array $data, array $dataTypes)
  • int $unitId: usually ID of Modbus device
  • int $reference: Reference in the device memory (e.g. in device WAGO 750-841, memory MW0 starts at address 12288)
  • array $data: Array of values to be written.
  • array $dataTypes: Array of types of values to be written. The array should consists of string "INT", "DINT" and "REAL".
__toString (line 71)

__toString

Magic method

void __toString ()

Documentation generated on Tue, 09 Jul 2013 23:46:23 +0200 by phpDocumentor 1.4.1