function rx_data = rx_data_from_hdf5(varargin) % Utility to extract OFDM Rx entries from HDF5 file % Two input arguments: % rx_data = rx_data_from_hdf5(hdf5_file_name, hdf5_dataset_path) % hdf5_file_name: Path (full or relative) of source HDF5 file (required) % hdf5_dataset_path: HDF5 path for dataset containing OFDM Rx entries % Defaults to '/RX_OFDM' % % The HDF5 file fed to this function should be generated by processing % raw log data from the 802.11 Reference Design with the wlan_exp_log % Python utilities. This utility expects numpy-processed log entries % *not* raw log data. Refer to the 802.11 Reference Design user guide % for more details on using the wlan_exp_log tools. if(nargin == 1) hdf5_filename = varargin{1}; dataset_name = '/RX_OFDM'; elseif(nargin == 2) hdf5_filename = varargin{1}; dataset_name = varargin{2}; else error('rx_data_from_hdf5 requires 1 or 2 input arguments: hdf5_file_name and hdf5_dataset_path') end rx_entries = h5read(hdf5_filename, dataset_name); rx_t = double(rx_entries.timestamp); rx_fcs = double((bitand(rx_entries.flags,1) == 1)); rx_h = double(rx_entries.chan_est); rx_pwr = double(rx_entries.power); % For MAX2829 RF interfaces 8-bit rx_gain_index value is: % [ 8]: 0 % [6:5]: RF gain index (0, 1, 2) % [4:0]: BB gain index (0, 1, ..., 31) rx_gain_index = uint8(rx_entries.rx_gain_index); rx_g_bb = double(mod(rx_gain_index, 32)); rx_g_rf = double(rx_gain_index/32); %Sanitze gain values rx_g_rf( rx_g_rf < 1 ) = 1; rx_g_rf( rx_g_rf > 3 ) = 3; rx_g_bb( rx_g_bb < 0 ) = 0; rx_g_bb( rx_g_bb > 31 ) = 31; %Convert chan ests from [I,Q] of Fix16_15 to complex doubles rx_h = rx_h ./2^15; rx_h = fftshift(squeeze(complex(rx_h(1,:,:), rx_h(2,:,:)))); %RF Gain: 1=0dB, 2=15dB, 3=30dB rx_g_rf_db = ((rx_g_rf - 1) * 15); %BB Gain: 2dB per step, approx [0, 63]dB total rx_g_bb_db = (rx_g_bb * 2); %Compute linear gain adjustment rx_h_g_adj = 10.^(-(rx_g_rf_db + rx_g_bb_db)/10); rx_h_g_adj = repmat(rx_h_g_adj, 1, size(rx_h, 1)).'; %Remove effect of Rx gains on each channel estimate rx_h = rx_h .* rx_h_g_adj; %Construct output struct rx_data.timestamp = rx_t; rx_data.g_bb_db = rx_g_bb_db; rx_data.g_rf_db = rx_g_rf_db; rx_data.fcs_result = rx_fcs; rx_data.pwr = rx_pwr; rx_data.chan_ests = rx_h.';