readMultipleRegisters(0, 12288, 10); } catch (Exception $e) { // Print error information if any echo $modbus; echo $e; exit; } // Received data echo "

Received Data

\n"; print_r($recData); // Conversion echo "

32 bits types

\n"; // Chunk the data array to set of 4 bytes $values = array_chunk($recData, 4); // Get float from REAL interpretation echo "

REAL to Float

\n"; foreach ($values as $bytes) echo PhpType::bytes2float($bytes) . "
"; // Get integer from DINT interpretation echo "

DINT to integer

\n"; foreach ($values as $bytes) echo PhpType::bytes2signedInt($bytes) . "
"; // Get integer of float from DINT interpretation echo "

DWORD to integer (or float)

\n"; foreach ($values as $bytes) echo PhpType::bytes2unsignedInt($bytes) . "
"; echo "

16 bit types

\n"; // Chunk the data array to set of 4 bytes $values = array_chunk($recData, 2); // Get signed integer from INT interpretation echo "

INT to integer

\n"; foreach ($values as $bytes) echo PhpType::bytes2signedInt($bytes) . "
"; // Get unsigned integer from WORD interpretation echo "

WORD to integer

\n"; foreach ($values as $bytes) echo PhpType::bytes2unsignedInt($bytes) . "
"; // Get string from STRING interpretation echo "

STRING to string

\n"; echo PhpType::bytes2string($recData) . "
";