from
Task execution profiling kit for Real-Time Workshop targets
by David Maclay
A set of tools and examples to implement task execution profiling for a Real-Time Workshop target
|
| exprofile_get_data_from_target1(connection, varargin)
|
function profData = exprofile_get_data_from_target1(connection, varargin)
%EXPROFILE_GET_DATA_FROM_TARGET1 retrieves profiling data from a target
%
% PROFDATA = EXPROFILE_GET_DATA_FROM_TARGET1(CONNECTION) retrieves profiling
% data PROFDATA from the TARGET using a CAN or Serial CONNECTION.
%
% PROFDATA = EXPROFILE_GET_DATA_FROM_TARGET1(CONNECTION, 'BitRate', BITRATE)
% uses the specified BITRATE.
%
% PROFDATA = EXPROFILE_GET_DATA_FROM_TARGET1(CONNECTION, 'SerialPort',
% SERIALPORT) uses the specified SERIALPORT, which should be one of COM1,
% COM2, etc.
%
% Copyright 1990-2006 The MathWorks, Inc.
% $Revision: 1.1.4.4.2.2 $ $Date: 2006/09/07 09:04:56 $
serial_port='COM1'; % default
bit_rate = [];
for k=1:length(varargin)/2
key = varargin{k*2-1};
value = varargin{k*2};
switch lower(key)
case 'serialport'
serial_port = value;
case 'bitrate'
bit_rate = value;
end
end
switch lower(connection)
case 'can'
if ~isempty(bit_rate)
can_bit_rate = bit_rate;
else
can_bit_rate = 500000;
end
local_check_bitrate(can_bit_rate);
first_data_timeout = 20;
channel = exprofile_detect_can_channel;
profData = exprofile_getdata_can(channel, can_bit_rate, first_data_timeout);
case 'serial'
if isempty(regexp(serial_port, 'COM[1-9][0-9]*'))
error([serial_port ' is not recognized as a valid serial port.' ...
'The serial port should be of the form e.g. COM1, COM2. '...
'Please make sure the function arguments are correct.']);
end
if ~isempty(bit_rate)
serial_bit_rate = bit_rate;
else
serial_bit_rate = 57600;
end
local_check_bitrate(serial_bit_rate);
first_data_timeout = 20;
profData = exprofile_getdata_serial(serial_port, serial_bit_rate, first_data_timeout);
end
% -------------------------------------------------------------------------
% -------------------------------------------------------------------------
% does some basic check on the bit rate
function local_check_bitrate(bit_rate)
if (~(isscalar(bit_rate) && isa(bit_rate, 'double') && (bit_rate > 0)))
error(['The specified bit rate, ' num2str(bit_rate) ', is invalid. ' ...
'The bit rate must be a positive scalar of type double. ' ...
'Please correct the specified bit rate.']);
end
%end function local_check_bitrate
% -------------------------------------------------------------------------
|
|
Contact us at files@mathworks.com