@@ 1893-1901 (lines=9) @@ | ||
1890 | $fcs = 0x07FF; // Frame Check Sequence |
|
1891 | // do most significant byte skipping the 2 most significant bits |
|
1892 | $data = hexdec($code_arr[0]) << 5; |
|
1893 | for ($bit = 2; $bit < 8; ++$bit) { |
|
1894 | if (($fcs ^ $data) & 0x400) { |
|
1895 | $fcs = ($fcs << 1) ^ $genpoly; |
|
1896 | } else { |
|
1897 | $fcs = ($fcs << 1); |
|
1898 | } |
|
1899 | $fcs &= 0x7FF; |
|
1900 | $data <<= 1; |
|
1901 | } |
|
1902 | // do rest of bytes |
|
1903 | for ($byte = 1; $byte < 13; ++$byte) { |
|
1904 | $data = hexdec($code_arr[$byte]) << 3; |
|
@@ 1905-1913 (lines=9) @@ | ||
1902 | // do rest of bytes |
|
1903 | for ($byte = 1; $byte < 13; ++$byte) { |
|
1904 | $data = hexdec($code_arr[$byte]) << 3; |
|
1905 | for ($bit = 0; $bit < 8; ++$bit) { |
|
1906 | if (($fcs ^ $data) & 0x400) { |
|
1907 | $fcs = ($fcs << 1) ^ $genpoly; |
|
1908 | } else { |
|
1909 | $fcs = ($fcs << 1); |
|
1910 | } |
|
1911 | $fcs &= 0x7FF; |
|
1912 | $data <<= 1; |
|
1913 | } |
|
1914 | } |
|
1915 | return $fcs; |
|
1916 | } |