且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何扩展pyserial的输入缓冲区大小

更新时间:2023-11-09 21:11:40

如果在Windows平台上运行代码,只需在代码中添加一行即可。

If you run your code on Windows platform, you simply need to add a line in your code.

ser.set_buffer_size(rx_size = 12800, tx_size = 12800)

其中12800是我选择的任意数字。您可以使接收(rx)和发送(tx)缓冲区最大为2147483647(等于2 ^ 31-1)

Where 12800 is an arbitrary number I chose. You can make receiving(rx) and transmitting(tx) buffer as big as 2147483647 (equal to 2^31 - 1)

这将允许您扩展输入缓冲区

this will allow you to expand the input buffer to get all of the returns at once.

请注意,由于这是建议,因此仅对某些驾驶员有效。该驱动程序可能不会接受您的建议,并会保留其原始缓冲区大小。

Be aware that this will work only with some drivers since it is a recommendation. The driver might not take your recommendation and will stick with its' original buffer size.