필터 지우기
필터 지우기

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

조회 수: 26 (최근 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

카테고리

Help CenterFile Exchange에서 串行端口设备에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!