Hello when I try to call this function I get the error :Error using serial_setup (line 18) Not enough input arguments.

function [s]=serial_setup(com)
s=serial(com);
set(s,'Baudrate',9600);
set(s,'Databits',8);
set(s,'Stopbits',1);
set(s,'Parity','none');
fopen(s);
b=99;
while b~='a'
b=fread(s,1,'uchar');
end
fscanf(s,'%d');
fprintf(s,'%c','a');
success=fscanf(s,'%c');
success(and)=[]; %delete ASCII 13
success(and)=[]; %delete ASCII 10
if success=='Serial Setup'
xbox=msgbox(success);uiwait(xbox);
end

 Accepted Answer

You cannot just run the function by clicking on the green Run button. You need to invoke it passing in a character vector that is the name of a serial port on your system. For example,
s = serial_setup('COM7');

More Answers (0)

Categories

Find more on Simulink in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!