| External Interfaces/API | ![]() |
The Serial Port Session
The serial port session comprises all the steps you are likely to take when communicating with a device connected to a serial port. These steps are:
serial creation function.
You can also configure properties during object creation. In particular, you may want to configure properties associated with serial port communications such as the baud rate, the number of data bits, and so on.
fopen function.
After the object is connected, you can alter device settings by configuring property values, read data, and write data.
set function or dot notation.
In practice, you can configure many of the properties at any time including during, or just after, object creation. Conversely, depending on your device settings and the requirements of your serial port application, you may be able to accept the default property values and skip this step.
fprintf or fwrite function, and read data from the device using the fgetl, fgets, fread, fscanf, or readasync function.
The serial port object behaves according to the previously configured or default property values.
fclose function, remove it from memory using the delete function, and remove it from the MATLAB workspace using the clear command.
The serial port session is reinforced in many of the serial port documentation examples. Refer to Example: Getting Started to see a basic example that uses the steps shown above.
| Getting Started with Serial I/O | Configuring and Returning Properties | ![]() |