Borrar filtros
Borrar filtros

如何更改串口的收发缓存的大小

26 visualizaciones (últimos 30 días)
Cheng Liu
Cheng Liu el 13 de Feb. de 2023
Respondida: Raghav el 4 de Abr. de 2023
我使用的serialport函数创建的串口,可以正常与外部设备建立连接
但是当我进行大批量的数据读取的时候发现报错了,错误提式大概是说读取的数据量要小于InputNuffSize的值
但是在查阅了serialport函数之后,并没有发现相关的函数可以修改输入输出缓存的值
相应的两个属性还都是只读的?
那请问该如何修改输入输出缓存呢

Respuestas (1)

Raghav
Raghav el 4 de Abr. de 2023
Hi,
Based on your question, I can understand that you need to know about changing the buffer size of the serial port.
In MATLAB, earlier, the input-output buffer size for a serial port can be modified by user explicitly by using the properties 'InputBufferSize' and 'OutputBufferSize' of serial function. These properties used to control the size of the input and output buffers in bytes, respectively.
But now it is recommended to use the serialport function as in this ‘InputBufferSize’ & ‘OutputBufferSize’ are automatically managed and sized as needed.
To check the official documentation to transition your code to serialport interface, please visit the following link:
Note that the maximum buffer size that can be set depends on the operating system and the hardware capabilities of your computer. Setting a buffer size that is too large may result in memory allocation errors or other issues.
Thanks,
Raghav Bansal

Productos


Versión

R2022a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!