
% BB9 connected to DH4, extracted by WAP
% First column is DH4 timestamp as seconds since power on
% 166535.560	WETA_BB90132	21	1	10	892	463	0	50	1071	406	1208	369	1493	506	1143	676	1113	715	1150	816	1013	856	107c
% 166536.560	WETA_BB90132	21	1	11	892	395	0	44	1071	390	1208	418	1493	476	1142	617	1113	757	1150	719	1013	829	1089
% 166537.560	WETA_BB90132	21	1	12	891	388	0	46	1071	376	1208	382	1493	473	1142	655	1113	798	1150	796	1013	878	109e
% 166538.560	WETA_BB90132	21	1	13	891	374	0	49	1071	351	1208	383	1493	458	1141	610	1113	681	1150	733	1013	789	107f
%
% 
function outp = Read_BB9(fname)

    disp(['Reading ' fname ' using Read_BB9...']);
    dat = textread(fname,'%s','delimiter','\n');
    
    formatstr = '%f WETA_BB9%*d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %x';
    ncols = 23; % sscanf should give us ncols values
    
    % predeclare size of output data matrix
    outp = repmat(-888,length(dat),ncols);
    
    for k = 1:length(dat)
        datrow = sscanf(dat{k}, formatstr)';
        if isempty(datrow) | size(datrow,2)~=ncols
            datrow = repmat(-888,1,ncols);
        end        
        outp(k,:) = datrow;
    end
    
return