Code covered by the BSD License  

Highlights from
CO2gui - lab control and automation

CO2gui - lab control and automation

by

 

06 Jan 2010 (Updated )

Software used for controlling and data logging lab equipment.

fibreobjchecksum(command)
function checkSum = fibreobjchecksum(command)
% FIBREOBJCHECKSUM returns the correct checksum for a command to/from FOR
% value = fibreobjchecksum(command) returns the checksum (only) for the
% command supplied.

% checks the number of arguments
error(nargchk(1, 1, nargin))

% checks the command
if ~isnumeric(command) || (~isscalar(command) && ~isvector(command)) || any(command ~= uint8(command))
    % errors
    error('Command not valid for calculating a checksum.')
end

% the checksum is the 8 least significant bits (i.e. without overflow), of
% the sum of all of the bytes
checkSum = bin2dec(sprintf('%d', bitget(sum(command), 8:-1:1)));

Contact us