protected function imb_crc11fcs($code_arr)
{
$genpoly = 0xf35;
// generator polynomial
$fcs = 0x7ff;
// Frame Check Sequence
// do most significant byte skipping the 2 most significant bits
$data = hexdec($code_arr[0]) << 5;
for ($bit = 2; $bit < 8; ++$bit) {
if (($fcs ^ $data) & 0x400) {
$fcs = $fcs << 1 ^ $genpoly;
} else {
$fcs = $fcs << 1;
}
$fcs &= 0x7ff;
$data <<= 1;
}
// do rest of bytes
for ($byte = 1; $byte < 13; ++$byte) {
$data = hexdec($code_arr[$byte]) << 3;
for ($bit = 0; $bit < 8; ++$bit) {
if (($fcs ^ $data) & 0x400) {
$fcs = $fcs << 1 ^ $genpoly;
} else {
$fcs = $fcs << 1;
}
$fcs &= 0x7ff;
$data <<= 1;
}
}
return $fcs;
}