Info

This question is closed. Reopen it to edit or answer.

Obtain sets of data using serial communication

1 view (last 30 days)
Shawn Chang
Shawn Chang on 19 Oct 2012
Closed: MATLAB Answer Bot on 20 Aug 2021
Hi all,
I wish to obtain sets of data which resulted from my robotic car through serial communication. The code that I written to obtain sets of from robotic car is as below. After troubleshooting for many time but the code still didn't worked.
s_port=serial('COM6','BaudRate',115200,'Parity','none'...
,'DataBits',8,'FlowControl','none');
set(s_port,'InputBufferSize',15,'OutputBufferSize',15,'Timeout',1);
fopen(s_port);
%send the time and speed to Robocar
fprintf(s_port,sprintf('%s %d', speed, sim_t));
%for loop to get receive granted signal for robotic car
for i=1:(sim_t*10)
access = fgetl(s_port);
if (access == 'OK')
break;
end
end
%for loop to obtain sets of data
for i=1:(sim_t*10)
data = fgetl(s_port);
pause(0.001);
end
  3 Comments
Walter Roberson
Walter Roberson on 21 Oct 2012
That is what it is intended to do: what happens instead? For example are any error messages produced?

Answers (1)

Walter Roberson
Walter Roberson on 19 Oct 2012
Do not use "==" to compare strings: use strcmp() instead.

Community Treasure Hunt

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

Start Hunting!