| @@ 2205-2213 (lines=9) @@ | ||
| 2202 | $fcs = 0x07FF; // Frame Check Sequence |
|
| 2203 | // do most significant byte skipping the 2 most significant bits |
|
| 2204 | $data = hexdec($code_arr[0]) << 5; |
|
| 2205 | for ($bit = 2; $bit < 8; ++$bit) { |
|
| 2206 | if (($fcs ^ $data) & 0x400) { |
|
| 2207 | $fcs = ($fcs << 1) ^ $genpoly; |
|
| 2208 | } else { |
|
| 2209 | $fcs = ($fcs << 1); |
|
| 2210 | } |
|
| 2211 | $fcs &= 0x7FF; |
|
| 2212 | $data <<= 1; |
|
| 2213 | } |
|
| 2214 | // do rest of bytes |
|
| 2215 | for ($byte = 1; $byte < 13; ++$byte) { |
|
| 2216 | $data = hexdec($code_arr[$byte]) << 3; |
|
| @@ 2217-2225 (lines=9) @@ | ||
| 2214 | // do rest of bytes |
|
| 2215 | for ($byte = 1; $byte < 13; ++$byte) { |
|
| 2216 | $data = hexdec($code_arr[$byte]) << 3; |
|
| 2217 | for ($bit = 0; $bit < 8; ++$bit) { |
|
| 2218 | if (($fcs ^ $data) & 0x400) { |
|
| 2219 | $fcs = ($fcs << 1) ^ $genpoly; |
|
| 2220 | } else { |
|
| 2221 | $fcs = ($fcs << 1); |
|
| 2222 | } |
|
| 2223 | $fcs &= 0x7FF; |
|
| 2224 | $data <<= 1; |
|
| 2225 | } |
|
| 2226 | } |
|
| 2227 | return $fcs; |
|
| 2228 | } |
|