Why do I receive a timeout error when I try to read in data through the serial object that I created in MATLAB 7.9 (R2009b)?

After setting up a serial object using the SERIAL command, I am writing to a serial device using the FPRINTF command. Immediately after the write, I do a read through the FSCANF command.
When I run this in the command line, I do not see any error; however when I put these commands in a script and run them, I get a timeout error.

 Accepted Answer

The issue happens because writing data to your instrument takes a finite amount of time. When you do a read immediately after the write operation, the write operation might not have been complete, and hence the timeout error occurs.
To workaround this issue, please have some wait time between the write and read operations. You can achieve this by using the PAUSE command.
For further details about the PAUSE command, please refer to the following documentation link:
http://www.mathworks.com/access/helpdesk/help/techdoc/ref/pause.html

More Answers (0)

Categories

Find more on Instrument Control Toolbox in Help Center and File Exchange

Products

Release

R2009b

Community Treasure Hunt

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

Start Hunting!