Controlling Access to the MATLAB Command Line
You control access to the MATLAB command line by specifying whether a read or write operation is synchronous or asynchronous.
A synchronous operation blocks access to the command line until the read or write function completes execution. An asynchronous operation does not block access to the command line, and you can issue additional commands while the read or write function executes in the background.
The terms "synchronous" and "asynchronous" are often used to describe how the serial port operates at the hardware level. The RS-232 standard supports an asynchronous communication protocol. Using this protocol, each device uses its own internal clock. The data transmission is synchronized using the start bit of the bytes, while one or more stop bits indicate the end of the byte. Refer to Serial Data Format for more information on start bits and stop bits. The RS-232 standard also supports a synchronous mode where all transmitted bits are synchronized to a common clock signal.
At the hardware level, most serial ports operate asynchronously. However, using the default behavior for many of the read and write functions, you can mimic the operation of a synchronous serial port.
|Note When used in this guide, the terms "synchronous" and "asynchronous" refer to whether read or write operations block access to the MATLAB command line. In other words, these terms describe how the software behaves, and not how the hardware behaves.|
The two main advantages of writing or reading data asynchronously are:
For example, because serial ports have separate read and write pins, you can simultaneously read and write data. This is illustrated below.
|Writing and Reading Data||Writing Data|