Serial - only reads one string.
Mostrar comentarios más antiguos
Hi
I have a microcontroller with a sensor. The uC sends out a string every tenth of a second to the COM-port. The string is filled with data XXX (Where XXX is 000-999)
Looks like this:
char output_verbose[] = {"XXX\r\n"};
The matlab-code is like this:
s1=serial('COM7','Baudrate',9600);
fopen(s1);
value=0;
str='';
sen=0;
j=1;
while(j<1000)
str=fscanf(s1);
sen=str2num(str);
accX(j)=sen;
plot(j,value);
drawnow;
j=j+1;
end;
fclose(s1);
delete(s1);
clear s1;
The probem after i have debugged a bit, is that when i want to read value number 2, the string is empty. It wont get the string from the COM-port again. And the uC sends the values 10 times a second, this is checked via PuTTY. I also have a LED that blinks everytime it sends.
Please help me
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre MATLAB en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!