Rev 1952 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed
| Rev 1952 | Rev 2205 | ||
|---|---|---|---|
| Line 261... | Line 261... | ||
| 261 | items.push(eval("(" + data + ")")); |
261 | items.push(eval("(" + data + ")")); |
| 262 | 262 | ||
| 263 | return items; |
263 | return items; |
| 264 | } |
264 | } |
| 265 | 265 | ||
| - | 266 | function crc8(data, length) |
|
| - | 267 | { |
|
| - | 268 | /* |
|
| - | 269 | CRC calculation |
|
| - | 270 | http://ghsi.de/CRC/index.php?Polynom=100110001&Message=4F90CB2E |
|
| - | 271 | with polynomial 100110001 |
|
| - | 272 | */ |
|
| - | 273 | var crc = 0; |
|
| - | 274 | for (var i=length-1; i>=0; i--) |
|
| - | 275 | { |
|
| - | 276 | var doInv = (((data>>i)&1) ^ (crc>>7)&1); |
|
| - | 277 | crc=(crc<<1)&0xff; |
|
| - | 278 | crc=crc|doInv; |
|
| - | 279 | crc=crc^((doInv<<4)|((doInv<<5))); |
|
| - | 280 | } |
|
| 266 | 281 | ||
| - | 282 | return crc; |
|
| - | 283 | } |
|
| 267 | 284 | ||
| 268 | - | ||
| - | 285 | function rshift(num, bits) { |
|
| - | 286 | num = num - (num % Math.pow(2,bits)); |
|
| - | 287 | return num / Math.pow(2,bits); |
|
| 269 | 288 | } |
|
| 270 | - | ||
| 271 | - | ||
| 272 | 289 | ||