1 | function output_struct = parse_phylog(filename, maxRows) |
---|
2 | % Field Sizes |
---|
3 | % RXPHYDUMP_SIZE_EVMPERSC = 256 (4*( 64 Fix32_26)) |
---|
4 | % RXPHYDUMP_SIZE_EVMPERSYM= 512 (4*(128 Fix32_14)) |
---|
5 | % RXPHYDUMP_SIZE_CHANEST = 256 (4*( 64 Fix32_30)) |
---|
6 | % |
---|
7 | % Record Format (1316 bytes max, if all fields are included): |
---|
8 | % [0:3] param0 |
---|
9 | % [4:7] param1 |
---|
10 | % [8:11] param2 |
---|
11 | % [12:15] param3 |
---|
12 | % [16] unsigned char structID; |
---|
13 | % [17] unsigned char nodeID; |
---|
14 | % [18:19] unsigned short seqNum; |
---|
15 | % [20] unsigned char pktType; |
---|
16 | % [21] unsigned char rxStatus; |
---|
17 | % [22] unsigned char includedData; |
---|
18 | % [23] unsigned char reserved0; |
---|
19 | % [24:25] unsigned short rssi; |
---|
20 | % [26:27] unsigned short rxGains; |
---|
21 | % [28:31] unsigned int cfoEst_coarse; (Fix32_32) |
---|
22 | % [32:35] unsigned int cfoEst_pilots; (Fix32_32) |
---|
23 | % [36:291] unsigned char evm_per_sc[RXPHYDUMP_SIZE_EVMPERSC] |
---|
24 | % [292:803] unsigned char evm_per_sym[RXPHYDUMP_SIZE_EVMPERSYM] |
---|
25 | % [804:1059] unsigned char chanest_AA[RXPHYDUMP_SIZE_CHANEST] |
---|
26 | % [1060:1315] unsigned char chanest_BA[RXPHYDUMP_SIZE_CHANEST] |
---|
27 | |
---|
28 | output_struct = struct; |
---|
29 | |
---|
30 | recsize = 1316; |
---|
31 | |
---|
32 | %H/P=1/2, payload=1412B |
---|
33 | syms_per_pkt = 128; |
---|
34 | |
---|
35 | fid = fopen(filename, 'r', 'b'); |
---|
36 | |
---|
37 | if(fid < 1) |
---|
38 | error('FILE', 'Error opening PHY log file!'); |
---|
39 | return; |
---|
40 | end |
---|
41 | |
---|
42 | |
---|
43 | fseek(fid, 0, 'bof'); |
---|
44 | output_struct.params0 = fread(fid, [maxRows], 'uint32=>double', recsize-4); |
---|
45 | |
---|
46 | fseek(fid, 4, 'bof'); |
---|
47 | output_struct.params1 = fread(fid, [maxRows], 'uint32=>double', recsize-4); |
---|
48 | |
---|
49 | fseek(fid, 8, 'bof'); |
---|
50 | output_struct.params2 = fread(fid, [maxRows], 'uint32=>double', recsize-4); |
---|
51 | |
---|
52 | fseek(fid, 12, 'bof'); |
---|
53 | output_struct.params3 = fread(fid, [maxRows], 'uint32=>double', recsize-4); |
---|
54 | |
---|
55 | fseek(fid, 16, 'bof'); |
---|
56 | output_struct.structIDs = fread(fid, [maxRows], '*uint8', recsize-1); |
---|
57 | |
---|
58 | fseek(fid, 18, 'bof'); |
---|
59 | output_struct.seqNums = fread(fid, [maxRows], 'uint16=>double', recsize-2); |
---|
60 | |
---|
61 | fseek(fid, 20, 'bof'); |
---|
62 | output_struct.pktTypes = fread(fid, [maxRows], '*uint8', recsize-1); |
---|
63 | |
---|
64 | fseek(fid, 21, 'bof'); |
---|
65 | output_struct.rxStatuses = fread(fid, [maxRows], '*uint8', recsize-1); |
---|
66 | |
---|
67 | fseek(fid, 24, 'bof'); |
---|
68 | rssis = fread(fid, [maxRows], 'uint16=>double', recsize-2); |
---|
69 | output_struct.rssis = rssis./16; |
---|
70 | |
---|
71 | fseek(fid, 26, 'bof'); |
---|
72 | rxGains = fread(fid, [maxRows], '*uint16', recsize-2); |
---|
73 | |
---|
74 | rxGains_A = bitand(rxGains, hex2dec('FF')); |
---|
75 | rxGains_B = bitshift(bitand(rxGains, hex2dec('FF00')), -8); |
---|
76 | output_struct.rxGainsRF_A = double(bitshift(bitand(rxGains_A, hex2dec('60')), -5)); |
---|
77 | output_struct.rxGainsBB_A = double(bitand(rxGains_A, hex2dec('1F'))); |
---|
78 | output_struct.rxGainsRF_B = double(bitshift(bitand(rxGains_B, hex2dec('60')), -5)); |
---|
79 | output_struct.rxGainsBB_B = double(bitand(rxGains_B, hex2dec('1F'))); |
---|
80 | |
---|
81 | fseek(fid, 28, 'bof'); |
---|
82 | cfoEsts_c = fread(fid, [maxRows], 'int32=>double', recsize-4); |
---|
83 | output_struct.cfoEsts_c = cfoEsts_c./2^32; |
---|
84 | |
---|
85 | fseek(fid, 32, 'bof'); |
---|
86 | cfoEsts_p = fread(fid, [maxRows], 'int32=>double', recsize-4); |
---|
87 | output_struct.cfoEsts_p = cfoEsts_p./2^32; |
---|
88 | |
---|
89 | fseek(fid, 36, 'bof'); |
---|
90 | evms_per_sc = fread(fid, [64, maxRows], '64*uint32=>double', recsize-256); |
---|
91 | output_struct.evms_per_sc = evms_per_sc./(syms_per_pkt*2^26); |
---|
92 | |
---|
93 | fseek(fid, 292, 'bof'); |
---|
94 | evms_per_sym = fread(fid, [128, maxRows], '128*uint32=>double', recsize-512); |
---|
95 | output_struct.evms_per_sym = evms_per_sym(1:syms_per_pkt, :)./(48*2^14); |
---|
96 | |
---|
97 | fseek(fid, 804, 'bof'); |
---|
98 | chanests_AA = fread(fid, [64, maxRows], '64*uint32=>double', recsize-256); |
---|
99 | output_struct.chanests_AA = sqrt(chanests_AA./2^30); |
---|
100 | |
---|
101 | fseek(fid, 1060, 'bof'); |
---|
102 | chanests_BA = fread(fid, [64, maxRows], '64*uint32=>double', recsize-256); |
---|
103 | output_struct.chanests_BA = sqrt(chanests_BA./2^30); |
---|
104 | |
---|
105 | fclose(fid); |
---|