Warning: Unexpected Warning: A timeout occurred before the Terminator was reached - Arduino
3 次查看(过去 30 天)
显示 更早的评论
I'm struggling to get to grips with MatLab's fscanf function. I have two Serial.println() within the Arduino loop:
void loop() {
sample = digitalRead(kHRM_Pin);
if (sample && (oldSample != sample)) {
Serial.println(BPM);
SDCardWrite();
}
oldSample = sample;
}
The function SDCardWrite also prints an error message in order to inform me that there was an error when writting to an SD card:
void SDCardWrite() {
...............
Serial.println("Error Writing To Card!");
}
}
I'm trying to capture the BPM variable using either fscanf(ard, '%d'); or fgetl(ard); I just keep getting various characters from the "error writing to sd card", or [] or Warning: Unsuccessful read: Matching failure in format.
More worryingly, when I try and close the serial object using fclose(ard);, MatLab hangs saying busy , then the computer (Mac) kernel crashes and restarts!
0 个评论
回答(1 个)
Sreeram Mohan
2014-9-25
Hi Darryl,
Suggestion 1: Did you try setting the timeout property of the serial to be of a higher value ? Just to make sure you give enough time for the serial to read ? http://www.mathworks.in/help/matlab/matlab_external/timeout.html
Suggestion 2:
In your code on the arduino it looks like the values to serial are sent only when some conditions are met. Where as on the other hand the MATLAB code is running infinitely without this knowledge and expects a string to come in to it.
Instead could you send an error on serial say a Serial.println("error"); in the else part of the Arduino code and filter these errors out and only take datas that are not having the errors ?
This would definitely prove to be a better method to remove the warning that you are observing !
Hope this helps !!
Sreeram Mohan
另请参阅
类别
在 Help Center 和 File 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!