Code covered by the BSD License  

Highlights from
A Synchronized Mil-Std-188-110B Receiver

image thumbnail
from A Synchronized Mil-Std-188-110B Receiver by Dick Benson
Extends the shipping "188" modem. Features a synchronized 1200 bps / short interleave receiver.

print_text(snew)
function print_text(snew)
% Copywrite 2008-2010 The MathWorks, Inc. 
persistent htxt
persistent raw_data;

if isempty(findobj('tag','mil_188_text')) 
          figure('position',[5 25 600 330],'menu','none','tag','mil_188_text',...
                'name','Rx Output','numbertitle','off');
          htxt=uicontrol('style','edit','min',1,'max',20,...
                           'units','pixels','position',[5,20,595 300],...
                           'horizontalalignment','left','backgroundcolor',[0 0 0],...
                           'foregroundcolor',[0 1 0 ],'tag','htxt_tag',...
                            'FontName','Arial','FontSize',12,...
	                       'FontUnits','points','FontWeight','bold');
                       
    raw_data=[];  
    set(htxt,'string',{''}); drawnow;
else
    htxt=findobj('tag','htxt_tag');
end;


 if nargin==0 
      raw_data=[];  
      set(htxt,'string',{''}); drawnow;
   
     return
 end;

 
if isempty(htxt)
    disp('ERROR: Empty handle error in print_text.m')
elseif nargin==1
   % strip any leading zeros
   k=1;
   if sum(snew)>0
      while snew(k)==0
          k=k+1;     
      end;
      if k>4
         % start of Rx message 
         raw_data=[];  
         set(htxt,'string',{''});
      end;
      raw_data= [raw_data;snew(k:end)];
   else
      % disp('Received all zeros.')
   end;
   p  = find(raw_data==13);
   L  = length(p);
   Lr = length(raw_data);
   Lnew = length(snew');
   MAXLINE = 13;
   
   if (Lr>2*Lnew) && ~isempty(findstr(char(raw_data((Lr-2*Lnew):end)'),'EOM Mil-Std-188-110A/B'))
      eomflag=1; % EOM can stradle 2 consecutive new strings 
   else
      eomflag=0;
   end    
   if (L <= MAXLINE)
      set(htxt,'string',char(raw_data')); drawnow;     
   else
      if eomflag
         set(htxt,'string',char(raw_data')); drawnow;       
      else
         set(htxt,'string',char(raw_data(p(L-MAXLINE):end)')); drawnow;  
      end
   end;
end;

Contact us at files@mathworks.com