SoftwarePractice.org: Home | Courseware | Wiki | Archive

Checksum.m Code

From SoftwarePractice.org

%checksum.m
% this function find the check sum 
% If theres a error in checksome of the image
% then the flag set to be 1 if not flag is 0
%
%
function [checkN,cflag]= checksum(bc3)
% Check start
% j = 1:3 -> 3 bits
if (bc3(1)==1 && bc3(2)==0 && bc3(3)==1)
   check1=1;
else 
   check1=0;
   %error;
end
%Check last 3 bit
if(bc3(93)==1 && bc3(94)==0 && bc3(95)==1)
   check2=1;
else 
   check2=0;
end
%check middle 5 bit
if(bc3(46)==0 && bc3(47)==1 && bc3(48)==0 && bc3(49)==1 && bc3(50)==0)
   check3=1;
else 
   check3=0;
end
% set the flag for check some
%Cut first and last 3 bit (bc4)
if(check1==1 && check2==1 && check3==1)
   bc4=bc3(4:92);
   cflag=1;
else
   bc4=0;
   cflag=0;
end
%Output
checkN=bc4;



Back to Barcode Deciphering

Personal tools