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 dispositivo hardware Arduino®, un altro computer o uno strumento scientifico come un oscilloscopio o un generatore di funzioni. Per molte applicazioni con porta seriale, è possibile comunicare con lo strumento senza dover conoscere nel dettaglio il funzionamento della porta seriale stessa. La comunicazione tramite porta seriale viene stabilita con un oggetto serialport, che viene 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, l'oggetto serialport e lo strumento devono avere impostazioni di comunicazione identiche. Per ulteriori informazioni, consultare 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.
Avviso della porta seriale: impossibile leggere i dati
Provate questi rimedi se non ricevete dati e visualizzate il messaggio di avviso: 'serialport' impossibile leggere i dati.




