Interfaz de puerto serie
La comunicación en serie es el protocolo de bajo nivel más común para la comunicación entre dos o más dispositivos. Normalmente, un dispositivo es una computadora, mientras que el otro dispositivo puede ser un módem, una impresora, hardware Arduino®, otra computadora o un instrumento científico como un osciloscopio o un generador de funciones. Para muchas aplicaciones de puerto serie, puede comunicarse con su instrumento sin tener un conocimiento detallado de cómo funciona el puerto serie. La comunicación a través de un puerto serie se establece con un objeto serialport
, que se crea en el espacio de trabajo MATLAB®. Para obtener información sobre cómo crear un objeto serialport
, consulte Create Serial Port Object.
Antes de poder escribir o leer datos, el objeto serialport
y el instrumento deben tener configuraciones de comunicación idénticas. Para obtener más información, consulte Configure Serial Port Communication Settings .
Funciones
Apps
Serial Explorer | Communicate with devices connected to serial port (Desde R2021b) |
Bloques
Serial Configuration | Configure parameters for serial port |
Serial Receive | Receive binary data over serial port |
Serial Send | Send binary data over serial port |
Temas
- 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
serialport
instead ofserial
.
Solución de problemas
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.