source: ResearchApps/Measurement/warpnet_coprocessors/phy_logger/util/parse_phylog.m

Last change on this file was 1603, checked in by murphpo, 14 years ago
  • Property svn:executable set to *
File size: 3.5 KB
Line 
1function 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
28output_struct = struct;
29
30recsize = 1316;
31
32%H/P=1/2, payload=1412B
33syms_per_pkt = 128;
34
35fid = fopen(filename, 'r', 'b');
36
37if(fid < 1)
38    error('FILE', 'Error opening PHY log file!');
39    return;
40end
41
42
43fseek(fid, 0, 'bof');
44output_struct.params0 = fread(fid, [maxRows], 'uint32=>double', recsize-4);
45
46fseek(fid, 4, 'bof');
47output_struct.params1 = fread(fid, [maxRows],  'uint32=>double', recsize-4);
48
49fseek(fid, 8, 'bof');
50output_struct.params2 = fread(fid, [maxRows],  'uint32=>double', recsize-4);
51
52fseek(fid, 12, 'bof');
53output_struct.params3 = fread(fid, [maxRows],  'uint32=>double', recsize-4);
54
55fseek(fid, 16, 'bof');
56output_struct.structIDs = fread(fid, [maxRows],  '*uint8', recsize-1);
57
58fseek(fid, 18, 'bof');
59output_struct.seqNums = fread(fid, [maxRows],  'uint16=>double', recsize-2);
60
61fseek(fid, 20, 'bof');
62output_struct.pktTypes = fread(fid, [maxRows],  '*uint8', recsize-1);
63
64fseek(fid, 21, 'bof');
65output_struct.rxStatuses = fread(fid, [maxRows],  '*uint8', recsize-1);
66
67fseek(fid, 24, 'bof');
68rssis = fread(fid, [maxRows],  'uint16=>double', recsize-2);
69output_struct.rssis = rssis./16;
70
71fseek(fid, 26, 'bof');
72rxGains = fread(fid, [maxRows],  '*uint16', recsize-2);
73
74rxGains_A = bitand(rxGains, hex2dec('FF'));
75rxGains_B = bitshift(bitand(rxGains, hex2dec('FF00')), -8);
76output_struct.rxGainsRF_A = double(bitshift(bitand(rxGains_A, hex2dec('60')), -5));
77output_struct.rxGainsBB_A = double(bitand(rxGains_A, hex2dec('1F')));
78output_struct.rxGainsRF_B = double(bitshift(bitand(rxGains_B, hex2dec('60')), -5));
79output_struct.rxGainsBB_B = double(bitand(rxGains_B, hex2dec('1F')));
80
81fseek(fid, 28, 'bof');
82cfoEsts_c = fread(fid, [maxRows],  'int32=>double', recsize-4);
83output_struct.cfoEsts_c = cfoEsts_c./2^32;
84
85fseek(fid, 32, 'bof');
86cfoEsts_p = fread(fid, [maxRows],  'int32=>double', recsize-4);
87output_struct.cfoEsts_p = cfoEsts_p./2^32;
88
89fseek(fid, 36, 'bof');
90evms_per_sc = fread(fid, [64, maxRows], '64*uint32=>double', recsize-256);
91output_struct.evms_per_sc = evms_per_sc./(syms_per_pkt*2^26);
92
93fseek(fid, 292, 'bof');
94evms_per_sym = fread(fid, [128, maxRows], '128*uint32=>double', recsize-512);
95output_struct.evms_per_sym = evms_per_sym(1:syms_per_pkt, :)./(48*2^14);
96
97fseek(fid, 804, 'bof');
98chanests_AA = fread(fid, [64, maxRows], '64*uint32=>double', recsize-256);
99output_struct.chanests_AA = sqrt(chanests_AA./2^30);
100
101fseek(fid, 1060, 'bof');
102chanests_BA = fread(fid, [64, maxRows], '64*uint32=>double', recsize-256);
103output_struct.chanests_BA = sqrt(chanests_BA./2^30);
104
105fclose(fid);
Note: See TracBrowser for help on using the repository browser.