Line | |
---|
1 | function no_errors = check_80211_fcs(thePacketBytes) |
---|
2 | %Based on the C code example at: |
---|
3 | %http://www.netrino.com/Embedded-Systems/How-To/CRC-Calculation-C-Code |
---|
4 | %Uses slightly modified version of CRC-32: |
---|
5 | % No output XOR |
---|
6 | % No bit-order swapping on message or digest bytes |
---|
7 | |
---|
8 | %%% Modified from WARP OFDM ref design version, to comply with |
---|
9 | % normal CRC32 (no idea why I changed from CRC32 for the WARP PHY...) |
---|
10 | |
---|
11 | CRCPolynomial = hex2dec('04c11db7'); |
---|
12 | CRC_Table = CRC_table_gen(CRCPolynomial, 32); |
---|
13 | |
---|
14 | init_crc = hex2dec('ffffffff'); |
---|
15 | myData = thePacketBytes; |
---|
16 | %de2bi(49,'left-msb',8)) |
---|
17 | crc_accum = init_crc; |
---|
18 | for n=1:length(myData) |
---|
19 | x = bitshift(crc_accum,-24,32); |
---|
20 | %CRC32 would swap bit order here: |
---|
21 | x = bitxor(x, bi2de( de2bi(myData(n),'left-msb',8))); |
---|
22 | % x = bitxor(x, myData(n)); |
---|
23 | x = bitand(x,hex2dec('ff')); |
---|
24 | crc_accum = bitxor(bitshift(crc_accum,8,32),CRC_Table(x+1)); |
---|
25 | end |
---|
26 | |
---|
27 | CRC32 = crc_accum; |
---|
28 | |
---|
29 | |
---|
30 | if(CRC32 == hex2dec('C704DD7B')) |
---|
31 | no_errors = 1; |
---|
32 | else |
---|
33 | no_errors = 0; |
---|
34 | end |
---|
Note: See
TracBrowser
for help on using the repository browser.