Revise CRC calls and use php's internal functions

This commit is contained in:
Deon George
2021-07-21 20:52:17 +10:00
parent 7cd3b814bb
commit 2fdc6eabad
5 changed files with 41 additions and 118 deletions

View File

@@ -222,7 +222,7 @@ final class EMSI extends BaseProtocol implements CRCInterface,ZmodemInterface
$makedata = preg_replace('/0000/',sprintf('%04X',strlen($makedata)-14),$makedata,1);
/* EMSI crc16 */
$makedata .= sprintf('%04X',$this->CRC16USD(substr($makedata,2)));
$makedata .= sprintf('%04X',crc16(substr($makedata,2)));
return $makedata;
}
@@ -277,7 +277,7 @@ final class EMSI extends BaseProtocol implements CRCInterface,ZmodemInterface
sscanf(substr($str,strlen($str)-4),"%04X",$l);
/* Bad EMSI CRC */
if ($l != ($x = $this->CRC16USD(substr($str,2,strlen($str)-6)))) {
if ($l != ($x = crc16(substr($str,2,strlen($str)-6)))) {
Log::error(sprintf('%s: ! Bad EMSI_DAT CRC: [%04X], should be: [%04X]!',__METHOD__,$l,$x));
return 0;