Modbus TCP and UDP library for PHP., originally from code.google.com/p/phpmodbus
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
php-modbus/tests/PhpType/Bytes2RealTest.php

31 lines
693 B

<?php
namespace Tests\PhpType;
use PHPModbus\PhpType;
use PHPUnit_Framework_TestCase;
class Bytes2Real extends PHPUnit_Framework_TestCase
{
private $data = [
0 => 0,
1 => 0,
2 => 68,
3 => 122,
4 => 0,
5 => 0,
6 => 68,
7 => 250,
8 => 0,
9 => 0,
10 => 63,
11 => 160,
];
public function testByte2Real()
{
$this->assertEquals(1000, PhpType::bytes2float(array_slice($this->data, 0, 4)));
$this->assertEquals(2000, PhpType::bytes2float(array_slice($this->data, 4, 4)));
$this->assertEquals(1.25, PhpType::bytes2float(array_slice($this->data, 8, 4)));
}
}