使用pyserial刷新方法 [英] using pyserial flush method

查看:75
本文介绍了使用pyserial刷新方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在某处读到过使用flush是减少延迟所必需的.这是真的?

I've read somewhere that the use of flush is necessary to reduce lag. Is this true?

我不确定是否使用它.请帮助我了解它究竟做了什么.

I'm not really sure about using it. Please help me understand what it does exactly.

我已经检查了 pyserial 文档,但它没有给我太多信息.它说的是:

I've checked pyserial docs but it didnt give me much information. All it said was:

冲洗()像对象一样刷新文件.这是此类中的空操作,可能会被覆盖.

flush() Flush of file like objects. It’s a no-op in this class, may be overridden.

推荐答案

您发送/写入的信息可能会临时存储在缓冲区中,以便一次性写入更大的块.所以,如果你这样做:

Information you're sending/writing may be temporarily stored in a buffer, so that a larger chunk can be written in one go. So, if you do:

f = open("test.txt","w")
f.write("Hello")

test.txt 仍然是空的,直到你执行 f.flush() 来刷新缓冲区.f.close() 也会在关闭文件之前刷新缓冲区.

test.txt will still be empty, until you do f.flush() to flush the buffer. f.close() also flushes the buffer before closing the file.

你得到的文档说它是一个无操作"——一个无操作,这意味着如果你真的在使用那个类,它不会做任何事情.如果您使用的是子类,它可能会做一些事情.

The document you've got says that it's a "no-op" - a no-operation, meaning that if you're actually using that class, it doesn't do anything. If you're using a subclass, it might do something.

这篇关于使用pyserial刷新方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆