Interfaccia porta seriale
La comunicazione seriale è il protocollo di basso livello più comune per la comunicazione tra due o più dispositivi. Normalmente, un dispositivo è un computer, mentre l'altro può essere un modem, una stampante, un hardware Arduino®, un altro computer o uno strumento scientifico come un oscilloscopio o un generatore di funzioni. Per molte applicazioni che utilizzano porte seriali, è possibile comunicare con lo strumento senza avere una conoscenza approfondita del funzionamento della porta seriale. La comunicazione tramite una porta seriale viene stabilita con un oggetto serialport, creato nell'area di lavoro MATLAB®. Per informazioni sulla creazione di un oggetto serialport, vedere Create Serial Port Object.
Prima di poter scrivere o leggere dati, lo strumento e l’oggetto serialport devono avere impostazioni di comunicazione identiche. Per informazioni, vedere Configure Serial Port Communication Settings .
Funzioni
App
| Serial Explorer | Communicate with devices connected to serial port (Da R2021b) |
Blocchi
| Serial Configuration | Configure parameters for serial port |
| Serial Receive | Receive binary data over serial port |
| Serial Send | Send binary data over serial port |
Argomenti
- Serial Port Overview
Basic features of serial port communication.
- Create Serial Port Object
Establish a connection between MATLAB and the device using the serial port.
- Configure Serial Port Communication Settings
Set properties associated with the device baud rate and serial data format.
- Write and Read Serial Port Data
Write and read both text and binary data with a serial port device.
- Use Callbacks for Serial Port Communication
Enhance instrument communication by executing a callback function when a specified event occurs on the device.
- Use Serial Port Control Pins
Signal the presence of connected devices and control the flow of data using control pins.
- Transition Your Code to serialport Interface
Connect to serial port devices using
serialportinstead ofserial.
Risoluzione dei problemi
Troubleshooting Serial Port Interface
Troubleshoot the Serial Port interface.
Resolve Serial Port Connection Errors
Troubleshoot connecting to a serial port device.
Serialport Warning - Unable to Read All Data
Try these remedies when you receive some data, and you get the warning message: 'serialport' unable to read all requested data.
Serialport Warning - Unable to Read Any Data
Try these remedies when you receive no data, and you get the warning message: 'serialport' unable to read any data.



