Serial communication is the most common low-level protocol for communicating between two
or more devices. Typically, one device is a computer, while the other device can be a modem, a
printer, another computer, or a scientific instrument such as an oscilloscope or a function
generator. For many serial port applications, you can communicate with your instrument without
detailed knowledge of how the serial port works. Communication is established through a serial
serial, which you create in the MATLAB workspace. For
information about creating the serial object, see Create a Serial Port Object.
Before you can write or read data, both the serial port object and the instrument must have identical communication settings. For information, see Configure Communication Settings.
|Remove serial port object from memory|
|Disconnect serial port object from device|
|Read line of ASCII text from device and discard terminator|
|Read line of text from device and include terminator|
|Connect serial port object to device|
|Write text to device|
|Read binary data from device|
|Read ASCII data from device, and format as text|
|Write binary data to device|
|Serial port object properties|
|Determine whether serial port objects are valid|
|Read data asynchronously from device|
|Create serial port object|
|Send break to device connected to serial port|
|List of serial ports connected to your system|
|Configure or display serial port object properties|
|Stop asynchronous read and write operations|
|Remove serial port object from MATLAB workspace|
|Serial port object summary information|
|Event information when event occurs|
|Read serial port objects from memory to MATLAB workspace|
|Find visible and hidden serial port objects|
|Load serial port objects and variables into MATLAB workspace|
|Length of serial port object array|
|Record data and event information to file|
|Save serial port objects and variables to file|
|Size of serial port object array|
Serial port capabilities, supported interfaces, and supported platforms.
The serial port interface standard, signals and pin assignments, the serial data format, and finding serial port information for your platform.
These examples help you get started with the serial port interface.
Create a MATLAB® object that represents the serial I/O device. You can configure property values during object creation.
Establish a connection between MATLAB and the serial I/O device.
You can set values for baud rate, serial data format, parity checking, and other serial properties.
You can write data to the device and read data from the device. The data can be text or binary.
You can enhance the power and flexibility of your serial port communication by using events. An event occurs after a condition is met and might result in one or more callbacks.
You can use control pins to signal the presence of connected devices and control the flow of data.
Recording information to disk provides a permanent record of your serial port session, and is an easy way to debug your application. While the serial port object is connected to the device, you can record information, such as number of values, data, and event information, to a disk file.
You can save and load serial port objects.
After the serial communication is complete, you should disconnect the serial port object from the device and remove the object from memory and the workspace.
You can use serial port properties for reading and writing data, configuring the communication, performing callbacks, and other tasks. The properties are described here in detail.