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

17 ビュー (過去 30 日間)
Cheng Liu
Cheng Liu 2023 年 2 月 13 日
回答済み: Raghav 2023 年 4 月 4 日
我使用的serialport函数创建的串口,可以正常与外部设备建立连接
但是当我进行大批量的数据读取的时候发现报错了,错误提式大概是说读取的数据量要小于InputNuffSize的值
但是在查阅了serialport函数之后,并没有发现相关的函数可以修改输入输出缓存的值
相应的两个属性还都是只读的?
那请问该如何修改输入输出缓存呢

回答 (1 件)

Raghav
Raghav 2023 年 4 月 4 日
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

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!