setting an outputport to the function call type in an s function
Hello community.
I am working on a UDP receive block that is used with generated code for an embedded linux platform.
My goal is to have it output the message, message length and a function call output to process the message.
The block setup is currently like this
function sfcn_UDPReceive(block) %setup
tsamp = 1;
buff_len = 2;
%% Register number of input and output ports
block.NumInputPorts = 0;
block.NumOutputPorts = 2;
%% function call
%block.OutputPort(1); %Somehow set this to a function call? C code
%seems to suggest DatatypeID 9 is a function call, but it gives me an
%error when I use it here.
%% message length
block.OutputPort(2).Dimensions = 1;
block.OutputPort(2).DatatypeID = 7; %uint32
block.OutputPort(2).Complexity = ‘Real’;
block.OutputPort(2).SamplingMode = ‘sample’;
%% message
block.OutputPort(3).Dimensions = block.DialogPrm(buff_len).Data;
block.OutputPort(3).DatatypeID = 3; %uint8
block.OutputPort(3).Complexity = ‘Real’;
block.OutputPort(3).SamplingMode = ‘sample’;
% Number of S-Function parameters expected
% (tsamp, buff_len)
block.NumDialogPrms = 2;
block.SampleTimes = [block.DialogPrm(tsamp).Data 0];
block.RegBlockMethod(‘WriteRTW’, @WriteRTW);
end
function WriteRTW(block)
buff_len = 2; % make buff_len available to .tlc file
block.WriteRTWParam(‘string’, ‘buff_len’, num2str(block.DialogPrm(buff_len).Data));
end
How do I set block.OutputPort(1).DatatypeID to fcncall?
I have found examples of how to do it in C, which would then have to be compiled to mex files, but I like this interface being in regular matlab script.
The documentation for doing things this way seems way more scarse than that for the C-mex interface.Hello community.
I am working on a UDP receive block that is used with generated code for an embedded linux platform.
My goal is to have it output the message, message length and a function call output to process the message.
The block setup is currently like this
function sfcn_UDPReceive(block) %setup
tsamp = 1;
buff_len = 2;
%% Register number of input and output ports
block.NumInputPorts = 0;
block.NumOutputPorts = 2;
%% function call
%block.OutputPort(1); %Somehow set this to a function call? C code
%seems to suggest DatatypeID 9 is a function call, but it gives me an
%error when I use it here.
%% message length
block.OutputPort(2).Dimensions = 1;
block.OutputPort(2).DatatypeID = 7; %uint32
block.OutputPort(2).Complexity = ‘Real’;
block.OutputPort(2).SamplingMode = ‘sample’;
%% message
block.OutputPort(3).Dimensions = block.DialogPrm(buff_len).Data;
block.OutputPort(3).DatatypeID = 3; %uint8
block.OutputPort(3).Complexity = ‘Real’;
block.OutputPort(3).SamplingMode = ‘sample’;
% Number of S-Function parameters expected
% (tsamp, buff_len)
block.NumDialogPrms = 2;
block.SampleTimes = [block.DialogPrm(tsamp).Data 0];
block.RegBlockMethod(‘WriteRTW’, @WriteRTW);
end
function WriteRTW(block)
buff_len = 2; % make buff_len available to .tlc file
block.WriteRTWParam(‘string’, ‘buff_len’, num2str(block.DialogPrm(buff_len).Data));
end
How do I set block.OutputPort(1).DatatypeID to fcncall?
I have found examples of how to do it in C, which would then have to be compiled to mex files, but I like this interface being in regular matlab script.
The documentation for doing things this way seems way more scarse than that for the C-mex interface. Hello community.
I am working on a UDP receive block that is used with generated code for an embedded linux platform.
My goal is to have it output the message, message length and a function call output to process the message.
The block setup is currently like this
function sfcn_UDPReceive(block) %setup
tsamp = 1;
buff_len = 2;
%% Register number of input and output ports
block.NumInputPorts = 0;
block.NumOutputPorts = 2;
%% function call
%block.OutputPort(1); %Somehow set this to a function call? C code
%seems to suggest DatatypeID 9 is a function call, but it gives me an
%error when I use it here.
%% message length
block.OutputPort(2).Dimensions = 1;
block.OutputPort(2).DatatypeID = 7; %uint32
block.OutputPort(2).Complexity = ‘Real’;
block.OutputPort(2).SamplingMode = ‘sample’;
%% message
block.OutputPort(3).Dimensions = block.DialogPrm(buff_len).Data;
block.OutputPort(3).DatatypeID = 3; %uint8
block.OutputPort(3).Complexity = ‘Real’;
block.OutputPort(3).SamplingMode = ‘sample’;
% Number of S-Function parameters expected
% (tsamp, buff_len)
block.NumDialogPrms = 2;
block.SampleTimes = [block.DialogPrm(tsamp).Data 0];
block.RegBlockMethod(‘WriteRTW’, @WriteRTW);
end
function WriteRTW(block)
buff_len = 2; % make buff_len available to .tlc file
block.WriteRTWParam(‘string’, ‘buff_len’, num2str(block.DialogPrm(buff_len).Data));
end
How do I set block.OutputPort(1).DatatypeID to fcncall?
I have found examples of how to do it in C, which would then have to be compiled to mex files, but I like this interface being in regular matlab script.
The documentation for doing things this way seems way more scarse than that for the C-mex interface. level 2 s-function, simulink MATLAB Answers — New Questions