Warning: Unsuccessful read: The specified amount of data was not returned within the Timeout period.. "

조회 수: 38 (최근 30일)
Hi,
I am sending data to Arduino serially, and I want it to read them and return them back to me.
The MATLAB code is
s=serial('COM4','BaudRate',9600);
set(s, 'TimeOut', 10);
fopen(s);
for i = 1:50
fwrite(s, i, 'uint8');
rx(i) = fread(s, 1);
end
fclose(s);
The error message I get is: " Warning: Unsuccessful read: The specified amount of data was not returned within the Timeout period.. "
I have read some possible causes for that problem such as the TimeOut period which I turned to 10. However I still get the same message. Can anyone help please?

답변 (2개)

Arpita Agrawal
Arpita Agrawal 2018년 7월 16일
Is there a code that is running on Arduino which is sending data over serial. If so, please share that as well. There is a possibility that the timeout occurs even before the hardware is sending the data.
  댓글 수: 1
Angeliki Zafeiropoulou
Angeliki Zafeiropoulou 2018년 8월 6일
Hi and thank you for your answer. The arduino code is
char ibyte;
void setup()
{
Serial.begin(9600);
delay(2500);
}
void loop()
{
if(Serial.available()>0)
{
ibyte=Serial.read();
Serial.write(ibyte);
}
}

댓글을 달려면 로그인하십시오.


Arpita Agrawal
Arpita Agrawal 2018년 8월 7일
Hi Angeliki,
This implementation should work. Please verify that the Arduino board is able to send the data over Serial once using the 'DigitalReadSerial' example. If that is working well, probably you can try to increase the timeout value and check once. For further questions on this please contact MathWorks Technical Support.
Thanks Arpita
  댓글 수: 2
Angeliki Zafeiropoulou
Angeliki Zafeiropoulou 2018년 8월 7일
편집: Angeliki Zafeiropoulou 2018년 8월 7일
Hi Arpita,
thank you for your answer. I set the timeout in Matlab to 20 by adding the command s.Timeout=20; but nothings changed. I read that the default value is 10.
Do I also have to change adduino's timeout and make it the same for example?
Thanks, Angeliki
Arpita Agrawal
Arpita Agrawal 2018년 8월 7일
Hi,
You can try configuring the timeout on MATLAB, if you are able to read the data over Arduino Serial Monitor using the Example.
Thanks Arpita

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 MATLAB Support Package for Arduino Hardware에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by