Skip to content
Permalink
Browse files

Merge pull request #4 from Fav0rit/patch-1

Patch 1
  • Loading branch information...
directman66 committed Nov 9, 2018
2 parents 406ef4f + 4a6cbe5 commit d20dab73c6347b69afa33d56511b81bbfc4ec9ce
Showing with 14 additions and 3 deletions.
  1. +14 −3 modules/mercury/mercury.class.php
@@ -1555,10 +1555,21 @@ function merc_gd($socket252, $cmd, $factor = 1, $total = 0)
{
for ( $i = 0; $i < 4; $i++ )
{
if ( dechex(ord($result[$start_byte + $i * 3])) >= 40 )
$result[$start_byte + $i * 3] = chr(dechex(ord($result[$start_byte + $i * 3])) - 40);
//if ( dechex(ord($result[$start_byte + $i * 3])) >= 40 )
//$result[$start_byte + $i * 3] = chr(dechex(ord($result[$start_byte + $i * 3])) - 40);
if ( strlen($result) > $start_byte + 2 + $i * 3 )
$ret[$i] = hexdec($this->dd($result[$start_byte + $i * 3]).$this->dd($result[$start_byte + $i * 3 + 2]).$this->dd($result[$start_byte + $i * 3 + 1]))*$factor;
// Для всех запросов кроме мощности используем стандартный рассчет
if (substr($cmd,2,6)!='081600') {
$ret[$i] = hexdec($this->dd($result[$start_byte + $i * 3]).$this->dd($result[$start_byte + $i * 3 + 2]).$this->dd($result[$start_byte + $i * 3 + 1]))*$factor;
}
// При запросе мощности нужно маскировать два старших разряда старшего бита
else {
$hex = $this->dd($result[$start_byte + $i * 3]).$this->dd($result[$start_byte + $i * 3 + 2]).$this->dd($result[$start_byte + $i * 3 + 1]);
$bin=base_convert($hex, 16, 2);
// Обрезаем строку до 22 бит
while (strlen($bin)>22) $bin=substr($bin,1);
$ret[$i] = bindec($bin)*$factor;
}
}
}
else

0 comments on commit d20dab7

Please sign in to comment.
You can’t perform that action at this time.