<?php
//$DXPcmd = array(0x55,0x82,0x10,0x31,0x00,0x51,0x96);
$DXPcmd = array(0x55,0x82,0x10,0x31,0x00,0x51);
$DXPcmd = "558210310051";
$SUM=0;
for ($i=0; $i < strlen($DXPcmd)-1; $i+=2){
$SUM += hexdec($DXPcmd[$i].$DXPcmd[$i+1]);
}
$NOTSUM = ~$SUM;
echo dechex($NOTSUM);
$CHKSUM = bin2hex(dec2bin($NOTSUM) & dec2bin(3));
echo dechex($CHKSUM);
?>
preferences:
66.9 ms | 402 KiB | 5 Q