- Check if the input from Arduino actually has the Terminator 'CR'
- Increasing the timeout period
Warning: Unsuccessful read: A timeout occurred before the Terminator was reached. 'serial' unable to read any data.
96 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hello!
I am trying to read data from Arduino Uno but i get this error "Warning: Unsuccessful read: A timeout occurred before the Terminator was reached. 'serial' unable to read any data."
Can any one help me please ?
Thank you in advance!
clear All
close All
COM = serial('COM2','BaudRate',9600);%5,'Terminator','CR');
set(COM,'TimeOut',10)
fopen(COM);
interv = 240;
init_time = 1;
x =0;
while (init_time < interv)
b = fscanf(COM) ;
b = b(2:end-2);
b = bin2dec(b);
x = [x,b];
plot(x);
grid on ;
init_time = init_time+1;
drawnow;
end
fclose(COM);
delete(COM);
clear COM;
0 comentarios
Respuestas (1)
Aghamarsh Varanasi
el 28 de Dic. de 2020
Editada: Aghamarsh Varanasi
el 28 de Dic. de 2020
Hi,
Did you try using 'serialport' function to create the serial connection, as 'serial' function is not recommended to use due to a few compatibility issues.
Also, as the issue seems to be with timeout, you can check with two changes:
4 comentarios
Walter Roberson
el 14 de En. de 2023
https://knowledge.ni.com/KnowledgeArticleDetails?id=kA03q000000YGw9CAG&l=en-US shows how to use Process Explorer to determine which COM ports exist on your system, and how to figure out which process is already using the port.
Perrhaps your arduino is attached to a different port. Or perhaps some other process has it locked.
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!