Comunicazione seriale e USB
La comunicazione seriale è il protocollo di basso livello più diffuso per comunicare tra due o più dispositivi. Solitamente, un dispositivo è un computer mentre l'altro dispositivo può essere un modem, una stampante, l’hardware Arduino®, un altro computer o uno strumento scientifico come un oscilloscopio o un generatore di funzioni. Per molte applicazioni della porta seriale, è possibile comunicare con lo strumento senza conoscere nel dettaglio il funzionamento della porta seriale. La comunicazione attraverso una porta seriale è stabilita con un oggetto serialport, creato nel workspace di MATLAB®. Per informazioni sulla creazione di un oggetto serialport, vedere Create Serial Port Object.
Prima di poter scrivere o leggere i dati, l’oggetto serialport e lo strumento devono avere configurazioni di comunicazione identiche. Per informazioni, vedere Configure Serial Port Communication Settings.
Funzioni
App
| Serial Explorer | Communicate with devices connected to serial port (Da R2021b) |
| Hardware Manager | Discover and get started with your hardware (Da R2022a) |
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.
- Get Started with Hardware Manager
Get the apps and add-ons to access your hardware from MATLAB.
- 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.

