using pyserial flush method

懵懂的女人 提交于 2020-06-27 12:19:17

问题


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.

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.


回答1:


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 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.



来源:https://stackoverflow.com/questions/5116780/using-pyserial-flush-method

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!