Warning: Unexpected Warning: A timeout occurred before the Terminator was reached - Arduino
3 views (last 30 days)
Show older comments
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 Comments
Answers (1)
Sreeram Mohan
on 25 Sep 2014
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
See Also
Categories
Find more on MATLAB Support Package for Arduino Hardware in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!